many pslint fixes (#55862)

* Handles:

PSAvoidTrailingWhitespace
PSAvoidGlobalVars
PSAvoidAssignmentToAutomaticVariable
PSAvoidUsingCmdletAliases
PSAvoidUsingWriteHost
PSUseDeclaredVarsMoreThanAssignments
PSUsePSCredentialType
PSAvoidUsingPositionalParameters
PSAvoidUsingEmptyCatchBlock
PSAvoidUsingWMICmdlet

Replaced Write-Host with Write-Output
Added smart reboot check for win_domain feature installation
Modify the Creation of the pagefileto fit to CIM
Changelog fragment addition
Ignore.txt without fixes

* Changes after community reviews

* Change Out-Null to '> $null'

* Fixes after jborean93 comments

* Test

* Revert "Test"

This reverts commit 35c5c0648fa9d2868a18094d84954e53ffa28880.

* Removed all  > $null since they broke the module since the output got dumped

* run test again

* Revert "run test again"

This reverts commit 80eaf07143f9d8cb0116cbbc68a6a69c0ace840c.

* Changes after community review

* ignore PSUseDeclaredVarsMoreThanAssignments that are on a diffrent PR

* CI failed on extra line in ignore.txt

* Review changes

* PSlint errors

* Trail space

* send to null breaks the tests for  Set-Workgroup

* Lint stuff

* win_domain_user issue of indent.

* Update win_domain_user.ps1

* Update win_domain_membership.ps1

* Fix redirect to null

* lint space issue

* removed return from set-workgroup

* removed send to null
pull/53334/merge
Shachaf92 5 years ago committed by Jordan Borean
parent 5689cc08ce
commit 7ddcaafee5

@ -0,0 +1,2 @@
bugfixes:
- Fixed some PSlint warnings

@ -93,7 +93,7 @@ Function New-LegacySelfSignedCert
[int]$ValidDays = 1095
)
$hostnonFQDN = $env:computerName
$hostnonFQDN = $env:computerName
$hostFQDN = [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname
$SignatureAlgorithm = "SHA256"
@ -170,7 +170,7 @@ Function Enable-GlobalHttpFirewallAccess
# try to find/enable the default rule first
$add_rule = $false
$matching_rules = $fw.Rules | ? { $_.Name -eq "Windows Remote Management (HTTP-In)" }
$matching_rules = $fw.Rules | Where-Object { $_.Name -eq "Windows Remote Management (HTTP-In)" }
$rule = $null
If ($matching_rules) {
If ($matching_rules -isnot [Array]) {
@ -180,7 +180,7 @@ Function Enable-GlobalHttpFirewallAccess
Else {
# try to find one with the All or Public profile first
Write-Verbose "Found multiple existing HTTP firewall rules..."
$rule = $matching_rules | % { $_.Profiles -band 4 }[0]
$rule = $matching_rules | ForEach-Object { $_.Profiles -band 4 }[0]
If (-not $rule -or $rule -is [Array]) {
Write-Verbose "Editing an arbitrary single HTTP firewall rule (multiple existed)"
@ -310,7 +310,7 @@ if ($token_value -ne 1) {
# Make sure there is a SSL listener.
$listeners = Get-ChildItem WSMan:\localhost\Listener
If (!($listeners | Where {$_.Keys -like "TRANSPORT=HTTPS"}))
If (!($listeners | Where-Object {$_.Keys -like "TRANSPORT=HTTPS"}))
{
# We cannot use New-SelfSignedCertificate on 2012R2 and earlier
$thumbprint = New-LegacySelfSignedCert -SubjectName $SubjectName -ValidDays $CertValidityDays
@ -363,9 +363,9 @@ Else
# Check for basic authentication.
$basicAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "Basic"}
If ($DisableBasicAuth)
If ($DisableBasicAuth)
{
If (($basicAuthSetting.Value) -eq $true)
If (($basicAuthSetting.Value) -eq $true)
{
Write-Verbose "Disabling basic auth support."
Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $false
@ -375,8 +375,8 @@ If ($DisableBasicAuth)
{
Write-Verbose "Basic auth is already disabled."
}
}
Else
}
Else
{
If (($basicAuthSetting.Value) -eq $false)
{
@ -394,7 +394,7 @@ Else
If ($EnableCredSSP)
{
# Check for CredSSP authentication
$credsspAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where {$_.Name -eq "CredSSP"}
$credsspAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "CredSSP"}
If (($credsspAuthSetting.Value) -eq $false)
{
Write-Verbose "Enabling CredSSP auth support."

@ -5,7 +5,7 @@
# some Ansible modules that may use Powershell 3 features, so systems may need
# to be upgraded. This may be used by a sample playbook. Refer to the windows
# documentation on docs.ansible.com for details.
#
#
# - hosts: windows
# tasks:
# - script: upgrade_to_ps3.ps1
@ -20,7 +20,7 @@
if ($PSVersionTable.psversion.Major -ge 3)
{
write-host "Powershell 3 Installed already; You don't need this"
Write-Output "Powershell 3 Installed already; You don't need this"
Exit
}
@ -55,7 +55,7 @@ if (!(test-path $powershellpath))
# If the Operating System is above 6.2, then you already have PowerShell Version > 3
if ([Environment]::OSVersion.Version.Major -gt 6)
{
write-host "OS is new; upgrade not needed."
Write-Output "OS is new; upgrade not needed."
Exit
}
@ -67,11 +67,11 @@ $architecture = $ENV:PROCESSOR_ARCHITECTURE
if ($architecture -eq "AMD64")
{
$architecture = "x64"
}
}
else
{
$architecture = "x86"
}
$architecture = "x86"
}
if ($osminor -eq 1)
{

@ -10,7 +10,7 @@ Function Convert-StringToSnakeCase($string) {
# handle when there was nothing before the plural pattern
if ($replacement_string.StartsWith("_") -and -not $string.StartsWith("_")) {
$replacement_string = $replacement_string.Substring(1)
$replacement_string = $replacement_string.Substring(1)
}
$string = $replacement_string
}
@ -50,7 +50,7 @@ Function Convert-DictToSnakeCase($dict) {
$value = $dict_entry.Value
if ($value -is [Hashtable]) {
$snake_dict.$snake_key = Convert-DictToSnakeCase -dict $value
$snake_dict.$snake_key = Convert-DictToSnakeCase -dict $value
} elseif ($value -is [Array] -or $value -is [System.Collections.ArrayList]) {
$snake_dict.$snake_key = Convert-ListToSnakeCase -list $value
} else {

@ -360,7 +360,7 @@ Function Get-PendingRebootStatus
Check if reboot is required, if so notify CA.
Function returns true if computer has a pending reboot
#>
$featureData = Invoke-WmiMethod -EA Ignore -Name GetServerFeature -Namespace root\microsoft\windows\servermanager -Class MSFT_ServerManagerTasks
$featureData = Invoke-CimMethod -EA Ignore -Name GetServerFeature -Namespace root\microsoft\windows\servermanager -Class MSFT_ServerManagerTasks
$regData = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" "PendingFileRenameOperations" -EA Ignore
$CBSRebootStatus = Get-ChildItem "HKLM:\\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing" -ErrorAction SilentlyContinue| Where-Object {$_.PSChildName -eq "RebootPending"}
if(($featureData -and $featureData.RequiresReboot) -or $regData -or $CBSRebootStatus)
@ -375,4 +375,3 @@ Function Get-PendingRebootStatus
# this line must stay at the bottom to ensure all defined module parts are exported
Export-ModuleMember -Alias * -Function * -Cmdlet *

@ -246,7 +246,7 @@ namespace Ansible
finally
{
FindClose(findHandle);
}
}
}
if (result.Count > 1)
@ -271,7 +271,7 @@ namespace Ansible
IntPtr.Zero);
if (fileHandle.IsInvalid)
throw new LinkUtilWin32Exception(String.Format("CreateFile({0}) failed", linkPath));
throw new LinkUtilWin32Exception(String.Format("CreateFile({0}) failed", linkPath));
REPARSE_DATA_BUFFER buffer = new REPARSE_DATA_BUFFER();
UInt32 bytesReturned;
@ -428,7 +428,7 @@ Function New-Link($link_path, $link_target, $link_type) {
if (-not (Test-Path -LiteralPath $link_target)) {
throw "link_target '$link_target' does not exist, cannot create link"
}
switch($link_type) {
"link" {
$type = [Ansible.LinkType]::SymbolicLink

@ -79,13 +79,13 @@ Function Convert-ToSID {
$account = New-Object System.Security.Principal.NTAccount($username)
}
}
try {
$account_sid = $account.Translate([System.Security.Principal.SecurityIdentifier])
} catch {
Fail-Json @{} "account_name $account_name is not a valid account, cannot get SID: $($_.Exception.Message)"
}
return $account_sid.Value
}

@ -30,7 +30,7 @@ Function Get-MachineSid {
# admin account (ends with -500) and lops it off to get the machine sid.
$admins_sid = "S-1-5-32-544"
$admin_group = ([Security.Principal.SecurityIdentifier]$admins_sid).Translate([Security.Principal.NTAccount]).Value
$admin_group = ([Security.Principal.SecurityIdentifier]$admins_sid).Translate([Security.Principal.NTAccount]).Value
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$principal_context = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
@ -134,7 +134,7 @@ $osversion = [Environment]::OSVersion
if($gather_subset.Contains('all_ipv4_addresses') -or $gather_subset.Contains('all_ipv6_addresses')) {
$netcfg = Get-LazyCimInstance Win32_NetworkAdapterConfiguration
# TODO: split v4/v6 properly, return in separate keys
$ips = @()
Foreach ($ip in $netcfg.IPAddress) {
@ -212,9 +212,9 @@ if($gather_subset.Contains('distribution')) {
if($gather_subset.Contains('env')) {
$env_vars = @{ }
foreach ($item in Get-ChildItem Env:) {
$name = $item | select -ExpandProperty Name
$name = $item | Select-Object -ExpandProperty Name
# Powershell ConvertTo-Json fails if string ends with \
$value = ($item | select -ExpandProperty Value).TrimEnd("\")
$value = ($item | Select-Object -ExpandProperty Value).TrimEnd("\")
$env_vars.Add($name, $value)
}
@ -226,7 +226,7 @@ if($gather_subset.Contains('env')) {
if($gather_subset.Contains('facter')) {
# See if Facter is on the System Path
Try {
$facter_exe = Get-Command facter -ErrorAction Stop
Get-Command facter -ErrorAction Stop > $null
$facter_installed = $true
} Catch {
$facter_installed = $false
@ -234,7 +234,7 @@ if($gather_subset.Contains('facter')) {
# Get JSON from Facter, and parse it out.
if ($facter_installed) {
&facter -j | Tee-Object -Variable facter_output | Out-Null
&facter -j | Tee-Object -Variable facter_output > $null
$facts = "$facter_output" | ConvertFrom-Json
ForEach($fact in $facts.PSObject.Properties) {
$fact_name = $fact.Name
@ -246,7 +246,7 @@ if($gather_subset.Contains('facter')) {
if($gather_subset.Contains('interfaces')) {
$netcfg = Get-LazyCimInstance Win32_NetworkAdapterConfiguration
$ActiveNetcfg = @()
$ActiveNetcfg += $netcfg | where {$_.ipaddress -ne $null}
$ActiveNetcfg += $netcfg | Where-Object {$_.ipaddress -ne $null}
$namespaces = Get-LazyCimInstance __Namespace -namespace root
if ($namespaces | Where-Object { $_.Name -eq "StandardCimv" }) {
@ -254,7 +254,7 @@ if($gather_subset.Contains('interfaces')) {
$guid_key = "InterfaceGUID"
$name_key = "Name"
} else {
$net_adapters = Get-LazyCimInstance Win32_NetworkAdapter
$net_adapters = Get-LazyCimInstance Win32_NetworkAdapter
$guid_key = "GUID"
$name_key = "NetConnectionID"
}
@ -412,7 +412,7 @@ if($gather_subset.Contains('windows_domain')) {
if($gather_subset.Contains('winrm')) {
$winrm_https_listener_parent_paths = Get-ChildItem -Path WSMan:\localhost\Listener -Recurse -ErrorAction SilentlyContinue | `
Where-Object {$_.PSChildName -eq "Transport" -and $_.Value -eq "HTTPS"} | select PSParentPath
Where-Object {$_.PSChildName -eq "Transport" -and $_.Value -eq "HTTPS"} | Select-Object PSParentPath
if ($winrm_https_listener_parent_paths -isnot [array]) {
$winrm_https_listener_parent_paths = @($winrm_https_listener_parent_paths)
}
@ -429,14 +429,16 @@ if($gather_subset.Contains('winrm')) {
$winrm_cert_thumbprints = @()
foreach ($https_listener in $https_listeners) {
$winrm_cert_thumbprints += $https_listener | where {$_.Name -EQ "CertificateThumbprint" } | select Value
$winrm_cert_thumbprints += $https_listener | Where-Object {$_.Name -EQ "CertificateThumbprint" } | Select-Object Value
}
$winrm_cert_expiry = @()
foreach ($winrm_cert_thumbprint in $winrm_cert_thumbprints) {
Try {
$winrm_cert_expiry += Get-ChildItem -Path Cert:\LocalMachine\My | where Thumbprint -EQ $winrm_cert_thumbprint.Value.ToString().ToUpper() | select NotAfter
} Catch {}
$winrm_cert_expiry += Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object Thumbprint -EQ $winrm_cert_thumbprint.Value.ToString().ToUpper() | Select-Object NotAfter
} Catch {
Add-Warning -obj $result -message "Error during certificate expiration retrieval: $($_.Exception.Message)"
}
}
$winrm_cert_expirations = $winrm_cert_expiry | Sort-Object NotAfter
@ -460,14 +462,14 @@ if($gather_subset.Contains('virtual')) {
$machine_role="guest"
}
"VirtualBox" {
$machine_type="VirtualBox"
"VirtualBox" {
$machine_type="VirtualBox"
$machine_role="guest"
}
"HVM domU" {
$machine_type="Xen"
$machine_role="guest"
$machine_role="guest"
}
default {
@ -475,7 +477,7 @@ if($gather_subset.Contains('virtual')) {
$machine_role="NA"
}
}
$ansible_facts += @{
ansible_virtualization_role = $machine_role
ansible_virtualization_type = $machine_type

@ -1,8 +1,8 @@
#!powershell
# Copyright: (c) 2018, Ansible Project
# Copyright: (c) 2018, Simon Baerlocher <s.baerlocher@sbaerlocher.ch>
# Copyright: (c) 2018, ITIGO AG <opensource@itigo.ch>
# Copyright: (c) 2018, Simon Baerlocher <s.baerlocher@sbaerlocher.ch>
# Copyright: (c) 2018, ITIGO AG <opensource@itigo.ch>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#Requires -Module Ansible.ModuleUtils.ArgvParser

@ -34,7 +34,6 @@ $force = Get-AnsibleParam -obj $params -name "force" -type "bool" -default $true
# used in query mode, contains the local files/directories/symlinks that are to be copied
$files = Get-AnsibleParam -obj $params -name "files" -type "list"
$directories = Get-AnsibleParam -obj $params -name "directories" -type "list"
$symlinks = Get-AnsibleParam -obj $params -name "symlinks" -type "list"
$result = @{
changed = $false

@ -513,19 +513,19 @@ Function ConvertTo-CredentialAttribute {
}
Function Get-DiffInfo {
param($Credential)
param($AnsibleCredential)
$diff = @{
alias = $Credential.TargetAlias
alias = $AnsibleCredential.TargetAlias
attributes = [System.Collections.ArrayList]@()
comment = $Credential.Comment
name = $Credential.TargetName
persistence = $Credential.Persist.ToString()
type = $Credential.Type.ToString()
username = $Credential.UserName
comment = $AnsibleCredential.Comment
name = $AnsibleCredential.TargetName
persistence = $AnsibleCredential.Persist.ToString()
type = $AnsibleCredential.Type.ToString()
username = $AnsibleCredential.UserName
}
foreach ($attribute in $Credential.Attributes) {
foreach ($attribute in $AnsibleCredential.Attributes) {
$attribute_info = @{
name = $attribute.Keyword
data = $null
@ -573,7 +573,7 @@ $type = switch ($type) {
$existing_credential = [Ansible.CredentialManager.Credential]::GetCredential($name, $type)
if ($null -ne $existing_credential) {
$module.Diff.before = Get-DiffInfo -Credential $existing_credential
$module.Diff.before = Get-DiffInfo -AnsibleCredential $existing_credential
}
if ($state -eq "absent") {
@ -654,7 +654,7 @@ if ($state -eq "absent") {
if (($new_keyword -cne $existing_keyword) -or ($new_value -ne $existing_value)) {
$attribute_changed = $true
break
}
}
}
}
@ -705,9 +705,8 @@ if ($state -eq "absent") {
} else {
# Get a new copy of the credential and use that to set the after diff
$new_credential = [Ansible.CredentialManager.Credential]::GetCredential($name, $type)
$module.Diff.after = Get-DiffInfo -Credential $new_credential
$module.Diff.after = Get-DiffInfo -AnsibleCredential $new_credential
}
}
$module.ExitJson()

@ -36,7 +36,6 @@ try {
} catch {
Fail-Json -obj $result -message "Failed to search the disks on the target: $($_.Exception.Message)"
}
[int32]$diskcount = $disks | Measure-Object | Select-Object -ExpandProperty Count
foreach ($disk in $disks) {
$disk_info = @{}
$pdisk = Get-PhysicalDisk -ErrorAction SilentlyContinue | Where-Object {

@ -32,7 +32,7 @@ If($state -eq "present") {
# the actual mount is async, so the CIMInstance result may not immediately contain the data we need
$retry_count = 0
While(-not $di.Attached -and $retry_count -lt 5) {
Sleep -Seconds 1 | Out-Null
Start-Sleep -Seconds 1 > $null
$di = $di | Get-DiskImage
$retry_count++
}
@ -70,7 +70,7 @@ ElseIf($state -eq "absent") {
If($di.Attached) {
$result.changed = $true
If(-not $check_mode) {
Dismount-DiskImage $image_path | Out-Null
Dismount-DiskImage $image_path > $null
}
}
}

@ -24,6 +24,9 @@ Function Write-DebugLog {
Write-Debug $msg
$log_path = $null
$log_path = Get-AnsibleParam -obj $params -name "log_path"
if($log_path) {
Add-Content $log_path $msg
}
@ -47,7 +50,7 @@ Function Get-NetAdapterLegacy {
@{Name="ifIndex"; Expression={$_.DeviceID}}
)
$res = Get-WmiObject @wmiargs | Select-Object -Property $wmiprop
$res = Get-CIMInstance @wmiargs | Select-Object -Property $wmiprop
If(@($res).Count -eq 0 -and -not $Name.Contains("*")) {
throw "Get-NetAdapterLegacy: No Win32_NetworkAdapter objects found with property 'NetConnectionID' equal to '$Name'"
@ -66,7 +69,7 @@ Function Get-DnsClientServerAddressLegacy {
$idx = Get-NetAdapter -Name $InterfaceAlias | Select-Object -ExpandProperty ifIndex
$adapter_config = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "Index=$idx"
$adapter_config = Get-CIMInstance Win32_NetworkAdapterConfiguration -Filter "Index=$idx"
return @(
# IPv4 values
@ -90,7 +93,7 @@ Function Set-DnsClientServerAddressLegacy {
$idx = Get-NetAdapter -Name $InterfaceAlias | Select-Object -ExpandProperty ifIndex
$adapter_config = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "Index=$idx"
$adapter_config = Get-CIMInstance Win32_NetworkAdapterConfiguration -Filter "Index=$idx"
If($ResetServerAddresses) {
$res = $adapter_config.SetDNSServerSearchOrder()
@ -157,7 +160,7 @@ Function Set-DnsClientAddresses
)
Write-DebugLog ("Setting DNS addresses for adapter {0} to ({1})" -f $adapter_name, ($ipv4_addresses -join ", "))
If ($null -eq $ipv4_addresses) {
Set-DnsClientServerAddress -InterfaceAlias $adapter_name -ResetServerAddress
}
@ -166,7 +169,7 @@ Function Set-DnsClientAddresses
# this silently ignores invalid IPs, so we validate parseability ourselves up front...
Set-DnsClientServerAddress -InterfaceAlias $adapter_name -ServerAddresses $ipv4_addresses
}
# TODO: implement IPv6
}
@ -179,14 +182,13 @@ $ipv4_addresses = Get-AnsibleParam $params "ipv4_addresses" -FailIfEmpty $result
If($ipv4_addresses -is [string]) {
If($ipv4_addresses.Length -gt 0) {
$ipv4_address = @($ipv4_addresses)
$ipv4_addresses = @($ipv4_addresses)
}
Else {
$ipv4_addresses = @()
}
}
$global:log_path = Get-AnsibleParam $params "log_path"
$check_mode = Get-AnsibleParam $params "_ansible_check_mode" -Default $false
Try {
@ -206,7 +208,7 @@ Try {
Write-DebugLog ("Validating IP addresses ({0})" -f ($ipv4_addresses -join ", "))
$invalid_addresses = @($ipv4_addresses | ? { -not (Validate-IPAddress $_) })
$invalid_addresses = @($ipv4_addresses | Where-Object { -not (Validate-IPAddress $_) })
If($invalid_addresses.Count -gt 0) {
throw "Invalid IP address(es): ({0})" -f ($invalid_addresses -join ", ")
@ -235,4 +237,3 @@ Catch {
Throw
}

@ -18,6 +18,7 @@ Function Ensure-Prereqs {
$awf = Add-WindowsFeature AD-Domain-Services -WhatIf:$check_mode
$result.reboot_required = $awf.RestartNeeded
# FUTURE: Check if reboot necessary
return $true
}
return $false

@ -10,6 +10,8 @@ Set-StrictMode -Version 2
$ErrorActionPreference = "Stop"
$ConfirmPreference = "None"
$log_path = $null
Function Write-DebugLog {
Param(
[string]$msg
@ -21,7 +23,6 @@ Function Write-DebugLog {
$msg = "$date_str $msg"
Write-Debug $msg
if($log_path) {
Add-Content $log_path $msg
}
@ -39,17 +40,17 @@ Function Get-MissingFeatures {
}
$missing_features = @($features | Where-Object InstallState -ne Installed)
return ,$missing_features # no, the comma's not a typo- allows us to return an empty array
}
Function Ensure-FeatureInstallation {
# ensure RSAT-ADDS and AD-Domain-Services features are installed
Write-DebugLog "Ensuring required Windows features are installed..."
Write-DebugLog "Ensuring required Windows features are installed..."
$feature_result = Install-WindowsFeature $required_features
$result.reboot_required = $feature_result.RestartNeeded
If(-not $feature_result.Success) {
Exit-Json -message ("Error installing AD-Domain-Services and RSAT-ADDS features: {0}" -f ($feature_result | Out-String))
}
@ -59,7 +60,7 @@ Function Ensure-FeatureInstallation {
Function Get-DomainControllerDomain {
Write-DebugLog "Checking for domain controller role and domain name"
$sys_cim = Get-WmiObject Win32_ComputerSystem
$sys_cim = Get-CIMInstance Win32_ComputerSystem
$is_dc = $sys_cim.DomainRole -in (4,5) # backup/primary DC
# this will be our workgroup or joined-domain if we're not a DC
@ -106,9 +107,12 @@ $read_only = Get-AnsibleParam -obj $params -name "read_only" -type "bool" -defau
$site_name = Get-AnsibleParam -obj $params -name "site_name" -type "str" -failifempty $read_only
$state = Get-AnsibleParam -obj $params -name "state" -validateset ("domain_controller", "member_server") -failifempty $result
$log_path = Get-AnsibleParam -obj $params -name "log_path"
$_ansible_check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -default $false
$global:log_path = $log_path
Try {
# ensure target OS support; < 2012 doesn't have cmdlet support for DC promotion
If(-not (Get-Command Install-WindowsFeature -ErrorAction SilentlyContinue)) {
@ -208,7 +212,7 @@ Try {
if ($site_name) {
$install_params.SiteName = $site_name
}
$install_result = Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params
Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params
Write-DebugLog "Installation complete, trying to start the Netlogon service"
# The Netlogon service is set to auto start but is not started. This is
@ -253,7 +257,7 @@ Try {
$local_admin_secure = $local_admin_password | ConvertTo-SecureString -AsPlainText -Force
Write-DebugLog "Uninstalling domain controller..."
$uninstall_result = Uninstall-ADDSDomainController -NoRebootOnCompletion -LocalAdministratorPassword $local_admin_secure -Credential $domain_admin_cred
Uninstall-ADDSDomainController -NoRebootOnCompletion -LocalAdministratorPassword $local_admin_secure -Credential $domain_admin_cred
Write-DebugLog "Uninstallation complete, needs reboot..."
}
default { throw ("invalid state {0}" -f $state) }
@ -268,4 +272,3 @@ Catch {
Throw
}

@ -204,7 +204,7 @@ if ($state -eq "absent") {
if ($existing_value -cne $attribute_value) {
$replace_attributes.$attribute_name = $attribute_value
$diff_text += "-$attribute_name = $existing_value`n+$attribute_name = $attribute_value`n"
}
}
} else {
$add_attributes.$attribute_name = $attribute_value
$diff_text += "+$attribute_name = $attribute_value`n"

@ -9,9 +9,11 @@ Set-StrictMode -Version 2
$ErrorActionPreference = "Stop"
$log_path = $null
Function Write-DebugLog {
Param(
[string]$msg
[string]$msg
)
$DebugPreference = "Continue"
@ -19,7 +21,6 @@ Function Write-DebugLog {
$msg = "$date_str $msg"
Write-Debug $msg
if($log_path) {
Add-Content $log_path $msg
}
@ -45,11 +46,11 @@ Function Get-DomainMembershipMatch {
}
catch [System.Security.Authentication.AuthenticationException] {
Write-DebugLog "Failed to get computer domain. Attempting a different method."
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$user_principal = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current
If ($user_principal.ContextType -eq "Machine") {
$current_dns_domain = (Get-CimInstance -ClassName Win32_ComputerSystem -Property Domain).Domain
$domain_match = $current_dns_domain -eq $dns_domain_name
Write-DebugLog ("current domain {0} matches {1}: {2}" -f $current_dns_domain, $dns_domain_name, $domain_match)
@ -91,7 +92,7 @@ Function Get-HostnameMatch {
}
Function Is-DomainJoined {
return (Get-WmiObject Win32_ComputerSystem).PartOfDomain
return (Get-CIMInstance Win32_ComputerSystem).PartOfDomain
}
Function Join-Domain {
@ -135,7 +136,7 @@ Function Join-Domain {
}
Function Get-Workgroup {
return (Get-WmiObject Win32_ComputerSystem).Workgroup
return (Get-CIMInstance Win32_ComputerSystem).Workgroup
}
Function Set-Workgroup {
@ -145,15 +146,14 @@ Function Set-Workgroup {
Write-DebugLog ("Calling JoinDomainOrWorkgroup with workgroup {0}" -f $workgroup_name)
try {
$swg_result = (Get-WmiObject -ClassName Win32_ComputerSystem).JoinDomainOrWorkgroup($workgroup_name)
$swg_result = Get-CimInstance Win32_ComputerSystem | Invoke-CimMethod -MethodName JoinDomainOrWorkgroup -Arguments @{Name="$workgroup_name"}
} catch {
Fail-Json -obj $result -message "failed to call Win32_ComputerSystem.JoinDomainOrWorkgroup($workgroup_name): $($_.Exception.Message)"
}
if ($swg_result.ReturnValue -ne 0) {
Fail-Json -obj $result -message "failed to set workgroup through WMI, return value: $($swg_result.ReturnValue)"
return $swg_result}
}
}
Function Join-Workgroup {
@ -168,7 +168,7 @@ Function Join-Workgroup {
# 2012+ call the Workgroup arg WorkgroupName, but seem to accept
try {
$rc_result = Remove-Computer -Workgroup $workgroup_name -Credential $domain_cred -Force
Remove-Computer -Workgroup $workgroup_name -Credential $domain_cred -Force
} catch {
Fail-Json -obj $result -message "failed to remove computer from domain: $($_.Exception.Message)"
}
@ -176,7 +176,7 @@ Function Join-Workgroup {
# we're already on a workgroup- change it.
Else {
$swg_result = Set-Workgroup $workgroup_name
Set-Workgroup $workgroup_name
}
}
@ -211,6 +211,8 @@ Else { # workgroup
}
}
$global:log_path = $log_path
Try {
$hostname_match = If($hostname) { Get-HostnameMatch $hostname } Else { $true }
@ -247,7 +249,7 @@ Try {
$join_args.domain_ou_path = $domain_ou_path
}
$join_result = Join-Domain @join_args
Join-Domain @join_args
# this change requires a reboot
$result.reboot_required = $true
@ -262,7 +264,7 @@ Try {
$rename_args.DomainCredential = $domain_cred
}
$rename_result = Rename-Computer @rename_args
Rename-Computer @rename_args
# this change requires a reboot
$result.reboot_required = $true
@ -285,14 +287,14 @@ Try {
If(-not $_ansible_check_mode) {
If(-not $workgroup_match) {
Write-DebugLog ("setting workgroup to {0}" -f $workgroup_name)
$join_wg_result = Join-Workgroup -workgroup_name $workgroup_name -domain_admin_user $domain_admin_user -domain_admin_password $domain_admin_password
Join-Workgroup -workgroup_name $workgroup_name -domain_admin_user $domain_admin_user -domain_admin_password $domain_admin_password
# this change requires a reboot
$result.reboot_required = $true
}
If(-not $hostname_match) {
Write-DebugLog ("setting hostname to {0}" -f $hostname)
$rename_result = Rename-Computer -NewName $hostname
Rename-Computer -NewName $hostname
# this change requires a reboot
$result.reboot_required = $true

@ -400,4 +400,3 @@ if ($test_result.InDesiredState -ne $true) {
}
$module.ExitJson()

@ -48,11 +48,11 @@ namespace Ansible.Command {
[DllImport("kernel32.dll", EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetFinalPathNameByHandle(IntPtr handle, [In, Out] StringBuilder path, int bufLen, int flags);
[DllImport("kernel32.dll", EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess,
[DllImport("kernel32.dll", EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess,
int dwShareMode, IntPtr SecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
public static string GetSymbolicLinkTarget(System.IO.DirectoryInfo symlink) {
public static string GetSymbolicLinkTarget(System.IO.DirectoryInfo symlink) {
SafeFileHandle directoryHandle = CreateFile(symlink.FullName, 0, 2, System.IntPtr.Zero, CREATION_DISPOSITION_OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, System.IntPtr.Zero);
if(directoryHandle.IsInvalid)
throw new Win32Exception(Marshal.GetLastWin32Error());
@ -63,9 +63,9 @@ namespace Ansible.Command {
if (size<0)
throw new Win32Exception(Marshal.GetLastWin32Error()); // The remarks section of GetFinalPathNameByHandle mentions the return being prefixed with "\\?\" // More information about "\\?\" here -> http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx
if (path[0] == '\\' && path[1] == '\\' && path[2] == '?' && path[3] == '\\')
return path.ToString().Substring(4);
else
return path.ToString();
return path.ToString().Substring(4);
else
return path.ToString();
}
}
}
@ -177,7 +177,7 @@ Function Assert-Size($info) {
$size_pattern = '^(-?\d+)(b|k|m|g|t)?$'
$match = $size -match $size_pattern
if ($match) {
[int]$specified_size = $matches[1]
[int]$specified_size = $matches[1]
if ($null -eq $matches[2]) {
$chosen_byte = 'b'
} else {
@ -254,20 +254,19 @@ Function Get-FileStat($file) {
} elseif ($file.PSIsContainer) {
$isdir = $true
$share_info = Get-WmiObject -Class Win32_Share -Filter "Path='$($file.Fullname -replace '\\', '\\')'"
$share_info = Get-CIMInstance -Class Win32_Share -Filter "Path='$($file.Fullname -replace '\\', '\\')'"
if ($null -ne $share_info) {
$isshared = $true
$file_stat.sharename = $share_info.Name
}
# only get the size of a directory if there are files (not directories) inside the folder
# Get-ChildItem -LiteralPath does not work properly on older OS', use .NET instead
$dir_files = @()
try {
$dir_files = $file.EnumerateFiles("*", [System.IO.SearchOption]::AllDirectories)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
$size = 0
foreach ($dir_file in $dir_files) {
$size += $dir_file.Length
@ -304,7 +303,6 @@ Function Get-FilesInFolder($path) {
$dir_files = $dir.EnumerateFileSystemInfos("*", [System.IO.SearchOption]::TopDirectoryOnly)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
foreach ($item in $dir_files) {
if ($item -is [System.IO.DirectoryInfo] -and $recurse) {
if (($item.Attributes -like '*ReparsePoint*' -and $follow) -or ($item.Attributes -notlike '*ReparsePoint*')) {
@ -350,7 +348,7 @@ foreach ($path in $paths_to_check) {
$result.examined = $new_examined
if ($info -ne $false) {
$files = $result.Files
$files = $result.Files
$files += $info
$new_matched = $result.matched + 1

@ -49,7 +49,7 @@ Function Extract-MSU($msu) {
if ($LASTEXITCODE -ne 0) {
Fail-Json $result "failed to run expand.exe $($expand_args): RC = $LASTEXITCODE"
}
return $output_path
}
@ -87,7 +87,7 @@ Function Get-HotfixMetadataFromFile($extract_path) {
Fail-Json $result "failed to get metadata xml inside MSU file, cannot get hotfix metadata required for this task"
}
[xml]$xml = Get-Content -Path $metadata_path.FullName
$cab_source_filename = $xml.unattend.servicing.package.source.GetAttribute("location")
$cab_source_filename = Split-Path -Path $cab_source_filename -Leaf
$cab_file = Join-Path -Path $extract_path -ChildPath $cab_source_filename

@ -169,7 +169,7 @@ Function Convert-ToPropertyValue($pool, $attribute_key, $attribute_value) {
# Ensure WebAdministration module is loaded
if ($null -eq (Get-Module -Name "WebAdministration" -ErrorAction SilentlyContinue)) {
Import-Module WebAdministration
$web_admin_dll_path = Join-Path $env:SystemRoot system32\inetsrv\Microsoft.Web.Administration.dll
$web_admin_dll_path = Join-Path $env:SystemRoot system32\inetsrv\Microsoft.Web.Administration.dll
Add-Type -Path $web_admin_dll_path
}

@ -372,6 +372,6 @@ ElseIf (-not $current_bindings -and $state -eq 'present')
$result.binding_info = Create-BindingInfo $web_binding
} else {
$result.binding_info = $null
}
}
Exit-Json $result
}

@ -18,14 +18,13 @@ $state = Get-AnsibleParam -obj $params -name "state" -type "str" -validateset "a
$bind_port = Get-AnsibleParam -obj $params -name "port" -type "int"
$bind_ip = Get-AnsibleParam -obj $params -name "ip" -type "str"
$bind_hostname = Get-AnsibleParam -obj $params -name "hostname" -type "str"
$bind_ssl = Get-AnsibleParam -obj $params -name "ssl" -type "str"
# Custom site Parameters from string where properties
# are separated by a pipe and property name/values by colon.
# Ex. "foo:1|bar:2"
$parameters = Get-AnsibleParam -obj $params -name "parameters" -type "str"
if($null -ne $parameters) {
$parameters = @($parameters -split '\|' | ForEach {
$parameters = @($parameters -split '\|' | ForEach-Object {
return ,($_ -split "\:", 2);
})
}
@ -43,7 +42,7 @@ $result = @{
}
# Site info
$site = Get-Website | Where { $_.Name -eq $name }
$site = Get-Website | Where-Object { $_.Name -eq $name }
Try {
# Add site
@ -102,7 +101,7 @@ Try {
$result.changed = $true
}
$site = Get-Website | Where { $_.Name -eq $name }
$site = Get-Website | Where-Object { $_.Name -eq $name }
If($site) {
# Change Physical Path if needed
if($physical_path) {
@ -127,7 +126,7 @@ Try {
# Set properties
if($parameters) {
$parameters | foreach {
$parameters | ForEach-Object {
$property_value = Get-ItemProperty "IIS:\Sites\$($site.Name)" $_[0]
switch ($property_value.GetType().Name)
@ -137,7 +136,7 @@ Try {
}
if((-not $parameter_value) -or ($parameter_value) -ne $_[1]) {
Set-ItemProperty "IIS:\Sites\$($site.Name)" $_[0] $_[1]
Set-ItemProperty -LiteralPath "IIS:\Sites\$($site.Name)" $_[0] $_[1]
$result.changed = $true
}
}
@ -163,7 +162,7 @@ Catch
if ($state -ne 'absent')
{
$site = Get-Website | Where { $_.Name -eq $name }
$site = Get-Website | Where-Object { $_.Name -eq $name }
}
if ($site)

@ -48,5 +48,5 @@ $result.sent_localtime = $endsend_at.Trim()
if ($result.rc -ne 0 ) {
Fail-Json -obj $result -message "$output"
}
Exit-Json $result

@ -150,7 +150,7 @@ Function Test-RegistryProperty($path, $name) {
}
}
Function Get-ProgramMetadata($state, $path, $product_id, $credential, $creates_path, $creates_version, $creates_service) {
Function Get-ProgramMetadata($state, $path, $product_id, [PSCredential]$credential, $creates_path, $creates_version, $creates_service) {
# will get some metadata about the program we are trying to install or remove
$metadata = @{
installed = $false
@ -327,7 +327,7 @@ if ($state -eq "absent") {
if ($program_metadata.msi -eq $true) {
# we are uninstalling an msi
if ( -Not $log_path ) {
if ( -Not $log_path ) {
$temp_path = [System.IO.Path]::GetTempPath()
$log_file = [System.IO.Path]::GetRandomFileName()
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
@ -421,7 +421,7 @@ if ($state -eq "absent") {
if ($program_metadata.msi -eq $true) {
# we are installing an msi
if ( -Not $log_path ) {
if ( -Not $log_path ) {
$temp_path = [System.IO.Path]::GetTempPath()
$log_file = [System.IO.Path]::GetRandomFileName()
$log_path = Join-Path -Path $temp_path -ChildPath $log_file

@ -9,12 +9,12 @@
Function Remove-Pagefile($path, $whatif)
{
Get-WmiObject Win32_PageFileSetting | WHERE { $_.Name -eq $path } | Remove-WmiObject -WhatIf:$whatif
Get-CIMInstance Win32_PageFileSetting | Where-Object { $_.Name -eq $path } | Remove-CIMInstance -WhatIf:$whatif
}
Function Get-Pagefile($path)
{
Get-WmiObject Win32_PageFileSetting | WHERE { $_.Name -eq $path }
Get-CIMInstance Win32_PageFileSetting | Where-Object { $_.Name -eq $path }
}
########
@ -38,25 +38,24 @@ $result = @{
}
if ($removeAll) {
$currentPageFiles = Get-WmiObject Win32_PageFileSetting
$currentPageFiles = Get-CIMInstance Win32_PageFileSetting
if ($null -ne $currentPageFiles) {
$currentPageFiles | Remove-WmiObject -WhatIf:$check_mode | Out-Null
$currentPageFiles | Remove-CIMInstance -WhatIf:$check_mode > $null
$result.changed = $true
}
}
if ($null -ne $automatic) {
# change autmoatic managed pagefile
# change autmoatic managed pagefile
try {
$computerSystem = Get-WmiObject -Class win32_computersystem -EnableAllPrivileges
$computerSystem = Get-CIMInstance -Class win32_computersystem
} catch {
Fail-Json $result "Failed to query WMI computer system object $($_.Exception.Message)"
}
if ($computerSystem.AutomaticManagedPagefile -ne $automatic) {
$computerSystem.AutomaticManagedPagefile = $automatic
if (-not $check_mode) {
try {
$computerSystem.Put() | Out-Null
$computerSystem | Set-CimInstance -Property @{automaticmanagedpagefile="$automatic"} > $null
} catch {
Fail-Json $result "Failed to set AutomaticManagedPagefile $($_.Exception.Message)"
}
@ -91,7 +90,7 @@ if ($state -eq "absent") {
}
# Make sure drive is accessible
if (($testPath) -and (-not (Test-Path "${drive}:"))) {
if (($test_path) -and (-not (Test-Path "${drive}:"))) {
Fail-Json $result "Unable to access '${drive}:' drive"
}
@ -100,15 +99,13 @@ if ($state -eq "absent") {
# Set pagefile
if ($null -eq $curPagefile) {
try {
$pagefile = Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{name = $fullPath; InitialSize = 0; MaximumSize = 0} -WhatIf:$check_mode
$pagefile = New-CIMInstance -Class Win32_PageFileSetting -Arguments @{name = $fullPath;} -WhatIf:$check_mode
} catch {
Fail-Json $result "Failed to create pagefile $($_.Exception.Message)"
}
if (-not ($systemManaged -or $check_mode)) {
$pagefile.InitialSize = $initialSize
$pagefile.MaximumSize = $maximumSize
try {
$pagefile.Put() | out-null
$pagefile | Set-CimInstance -Property @{ InitialSize = $initialSize; MaximumSize = $maximumSize}
} catch {
$originalExceptionMessage = $($_.Exception.Message)
# Try workaround before failing
@ -124,7 +121,7 @@ if ($state -eq "absent") {
}
$pagingFilesValues += "$fullPath $initialSize $maximumSize"
try {
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" "PagingFiles" $pagingFilesValues
Set-ItemProperty -LiteralPath "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" "PagingFiles" $pagingFilesValues
} catch {
Fail-Json $result "Failed to set pagefile settings to the registry for workaround $($_.Exception.Message) Original exception: $originalExceptionMessage"
}
@ -134,9 +131,9 @@ if ($state -eq "absent") {
}else
{
$CurPageFileSystemManaged = (Get-CimInstance -ClassName win32_Pagefile -Property 'System' -Filter "name='$($fullPath.Replace('\','\\'))'").System
if ((-not $check_mode) -and
-not ($systemManaged -or $CurPageFileSystemManaged) -and
( ($curPagefile.InitialSize -ne $initialSize) -or
if ((-not $check_mode) -and
-not ($systemManaged -or $CurPageFileSystemManaged) -and
( ($curPagefile.InitialSize -ne $initialSize) -or
($curPagefile.maximumSize -ne $maximumSize)))
{
$curPagefile.InitialSize = $initialSize
@ -158,7 +155,7 @@ if ($state -eq "absent") {
}
$pagingFilesValues += "$fullPath $initialSize $maximumSize"
try {
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" "PagingFiles" $pagingFilesValues
Set-ItemProperty -LiteralPath "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "PagingFiles" -Value $pagingFilesValues
} catch {
Fail-Json $result "Failed to set pagefile settings to the registry for workaround $($_.Exception.Message) Original exception: $originalExceptionMessage"
}
@ -171,7 +168,7 @@ if ($state -eq "absent") {
if ($null -eq $drive) {
try {
$pagefiles = Get-WmiObject Win32_PageFileSetting
$pagefiles = Get-CIMInstance Win32_PageFileSetting
} catch {
Fail-Json $result "Failed to query all pagefiles $($_.Exception.Message)"
}
@ -192,12 +189,12 @@ if ($state -eq "absent") {
caption = $currentPagefile.Caption
description = $currentPagefile.Description
}
$result.pagefiles += $currentPagefileObject
$result.pagefiles += ,$currentPagefileObject
}
# Get automatic managed pagefile state
try {
$result.automatic_managed_pagefiles = (Get-WmiObject -Class win32_computersystem).AutomaticManagedPagefile
$result.automatic_managed_pagefiles = (Get-CIMInstance -Class win32_computersystem).AutomaticManagedPagefile
} catch {
Fail-Json $result "Failed to query automatic managed pagefile state $($_.Exception.Message)"
}

@ -78,8 +78,8 @@ $module.Result.ansible_facts = @{
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
ansible_os_product_key = $product_key
ansible_os_license_edition = $winlicense_edition
ansible_os_license_channel = $winlicense_channel
ansible_os_license_status = $winlicense_status
ansible_os_license_channel = $winlicense_channel
ansible_os_license_status = $winlicense_status
}
$module.ExitJson()

@ -9,7 +9,7 @@ function Get-EnabledPlugins($rabbitmq_plugins_cmd)
{
$list_plugins_cmd = "$rabbitmq_plugins_cmd list -E -m"
try {
$enabled_plugins = @(Invoke-Expression "& $list_plugins_cmd" | Where { $_ })
$enabled_plugins = @(Invoke-Expression "& $list_plugins_cmd" | Where-Object { $_ })
return ,$enabled_plugins
}
catch {
@ -115,7 +115,7 @@ if ($rabbitmq_bin_path) {
$enabled_plugins = Get-EnabledPlugins -rabbitmq_plugins_cmd $rabbitmq_plugins_cmd
if ($state -eq "enabled") {
$plugins_to_enable = $plugins | ?{-not ($enabled_plugins -contains $_)}
$plugins_to_enable = $plugins | Where-Object {-not ($enabled_plugins -contains $_)}
foreach ($plugin in $plugins_to_enable) {
if (-not $check_mode) {
Enable-Plugin -rabbitmq_plugins_cmd $rabbitmq_plugins_cmd -plugin_name $plugin
@ -128,7 +128,7 @@ if ($state -eq "enabled") {
}
if (-not $new_only) {
$plugins_to_disable = $enabled_plugins | ?{-not ($plugins -contains $_)}
$plugins_to_disable = $enabled_plugins | Where-Object {-not ($plugins -contains $_)}
foreach ($plugin in $plugins_to_disable) {
if (-not $check_mode) {
Disable-Plugin -rabbitmq_plugins_cmd $rabbitmq_plugins_cmd -plugin_name $plugin
@ -141,7 +141,7 @@ if ($state -eq "enabled") {
}
}
} else {
$plugins_to_disable = $enabled_plugins | ?{$plugins -contains $_}
$plugins_to_disable = $enabled_plugins | Where-Object {$plugins -contains $_}
foreach ($plugin in $plugins_to_disable) {
if (-not $check_mode) {
Disable-Plugin -rabbitmq_plugins_cmd $rabbitmq_plugins_cmd -plugin_name $plugin

@ -59,7 +59,7 @@ function Get-CAP([string] $name) {
# Fetch CAP user and computer groups in Down-Level Logon format
$cap.UserGroups = @(
Get-ChildItem -Path "$cap_path\UserGroups" |
Get-ChildItem -Path "$cap_path\UserGroups" |
Select-Object -ExpandProperty Name |
ForEach-Object { Convert-FromSID -sid (Convert-ToSID -account_name $_) }
)

@ -54,7 +54,7 @@ function Get-RAP([string] $name) {
# Fetch RAP user groups in Down-Level Logon format
$rap.UserGroups = @(
Get-ChildItem -Path "$rap_path\UserGroups" |
Get-ChildItem -Path "$rap_path\UserGroups" |
Select-Object -ExpandProperty Name |
ForEach-Object { Convert-FromSID -sid (Convert-ToSID -account_name $_) }
)

@ -14,7 +14,7 @@ Function Convert-RegistryPath {
)
$output = $Path -replace "HKLM:", "HKLM"
$output = $output -replace "HKCU:", "HKCU"
$output = $output -replace "HKCU:", "HKCU"
Return $output
}
@ -45,7 +45,7 @@ If ( $do_comparison -eq $True ) {
$guid = [guid]::NewGuid()
$exported_path = $env:TEMP + "\" + $guid.ToString() + 'ansible_win_regmerge.reg'
$expanded_compare_key = Convert-RegistryPath ($compare_to_key)
$expanded_compare_key = Convert-RegistryPath ($compare_to_key)
# export from the reg key location to a file
$reg_args = Argv-ToString -Arguments @("reg.exe", "EXPORT", $expanded_compare_key, $exported_path)

@ -39,13 +39,13 @@ Function Add-Route {
if (!($Route)){
try {
# Find Interface Index
$InterfaceIndex = Find-NetRoute -RemoteIPAddress $Gateway | Select -First 1 -ExpandProperty InterfaceIndex
$InterfaceIndex = Find-NetRoute -RemoteIPAddress $Gateway | Select-Object -First 1 -ExpandProperty InterfaceIndex
# Add network route
New-NetRoute -DestinationPrefix $Destination -NextHop $Gateway -InterfaceIndex $InterfaceIndex -RouteMetric $Metric -ErrorAction Stop -WhatIf:$CheckMode|out-null
New-NetRoute -DestinationPrefix $Destination -NextHop $Gateway -InterfaceIndex $InterfaceIndex -RouteMetric $Metric -ErrorAction Stop -WhatIf:$CheckMode|out-null
$result.changed = $true
$result.output = "Route added"
}
catch {
$ErrorMessage = $_.Exception.Message
@ -55,7 +55,7 @@ Function Add-Route {
else {
$result.output = "Static route already exists"
}
}
Function Remove-Route {
@ -69,7 +69,7 @@ Function Remove-Route {
if ($Route){
try {
Remove-NetRoute -DestinationPrefix $Destination -Confirm:$false -ErrorAction Stop -WhatIf:$CheckMode
Remove-NetRoute -DestinationPrefix $Destination -Confirm:$false -ErrorAction Stop -WhatIf:$CheckMode
$result.changed = $true
$result.output = "Route removed"
}
@ -84,7 +84,7 @@ Function Remove-Route {
}
# Set gateway if null
# Set gateway if null
if(!($gateway)){
$gateway = "0.0.0.0"
}

@ -42,7 +42,7 @@ $words = $null
if ($msg_file) {
if (-not (Test-Path -Path $msg_file)) {
$module.FailJson("Message file $msg_file could not be found or opened. Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file.")
}
}
$words = Get-Content $msg_file | Out-String
}
@ -53,7 +53,7 @@ if ($msg) {
if ($start_sound_path) {
if (-not (Test-Path -Path $start_sound_path)) {
$module.FailJson("Start sound file $start_sound_path could not be found or opened. Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file.")
}
}
if (-not $module.CheckMode) {
(new-object Media.SoundPlayer $start_sound_path).playSync()
}
@ -84,7 +84,7 @@ if ($words) {
if ($end_sound_path) {
if (-not (Test-Path -Path $end_sound_path)) {
$module.FailJson("End sound file $start_sound_path could not be found or opened. Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file.")
}
}
if (-not $module.CheckMode) {
(new-object Media.SoundPlayer $end_sound_path).playSync()
}

@ -81,7 +81,7 @@ Function Get-PropertyValue($task_property, $com, $property) {
return $null
} elseif ($raw_value.GetType().Name -eq "__ComObject") {
$com_values = @{}
$properties = Get-Member -InputObject $raw_value -MemberType Property | % {
Get-Member -InputObject $raw_value -MemberType Property | ForEach-Object {
$com_value = Get-PropertyValue -task_property $property -com $raw_value -property $_.Name
$com_values.$($_.Name) = $com_value
}
@ -297,7 +297,7 @@ if ($null -ne $name) {
$property_name = $property -replace "_"
$result.$property = @{}
$values = $task_definition.$property_name
Get-Member -InputObject $values -MemberType Property | % {
Get-Member -InputObject $values -MemberType Property | ForEach-Object {
if ($_.Name -notin $ignored_properties) {
$result.$property.$($_.Name) = (Get-PropertyValue -task_property $property -com $values -property $_.Name)
}
@ -312,14 +312,14 @@ if ($null -ne $name) {
$item = $collection.Item($i)
$item_info = @{}
Get-Member -InputObject $item -MemberType Property | % {
Get-Member -InputObject $item -MemberType Property | ForEach-Object {
if ($_.Name -notin $ignored_properties) {
$item_info.$($_.Name) = (Get-PropertyValue -task_property $property -com $item -property $_.Name)
}
}
$result.$property += $item_info
}
}
}
} else {
$result.task_exists = $false
}
@ -328,4 +328,3 @@ if ($null -ne $name) {
$result = Convert-DictToSnakeCase -dict $result
Exit-Json -obj $result

@ -27,7 +27,6 @@ if ($diff_mode) {
}
Function Run-SecEdit($arguments) {
$rc = $null
$stdout = $null
$stderr = $null
$log_path = [IO.Path]::GetTempFileName()
@ -165,7 +164,7 @@ if ($secedit_ini.$section.ContainsKey($key)) {
if ($diff_mode) {
$result.diff.prepared = @"
[$section]
+$key = $value
+$key = $value
"@
}
$secedit_ini.$section.$key = $value

@ -23,7 +23,7 @@ Function Cleanse-Stderr($raw_stderr) {
$matches["prenoise1"],
$matches["prenoise2"],
# filter out just the Error-tagged strings for now, and zap embedded CRLF chars
($clixml.Objs.ChildNodes | ? { $_.Name -eq 'S' } | ? { $_.S -eq 'Error' } | % { $_.'#text'.Replace('_x000D__x000A_','') } | Out-String),
($clixml.Objs.ChildNodes | Where-Object { $_.Name -eq 'S' } | Where-Object { $_.S -eq 'Error' } | ForEach-Object { $_.'#text'.Replace('_x000D__x000A_','') } | Out-String),
$matches["postnoise"]) | Out-String
return $merged_stderr.Trim()
@ -119,7 +119,7 @@ try {
# TODO: decode CLIXML stderr output (and other streams?)
$result.stdout = $command_result.stdout
$result.stderr = Cleanse-Stderr $command_result.stderr
$result.stderr = Cleanse-Stderr $command_result.stderr
$result.rc = $command_result.rc
$end_datetime = [DateTime]::UtcNow

@ -77,7 +77,7 @@ $module.Result.stat = @{ exists=$false }
Load-LinkUtils
$info, $link_info = Get-FileInfo -Path $path -Follow:$follow
If ($null -ne $info) {
If ($null -ne $info) {
$epoch_date = Get-Date -Date "01/01/1970"
$attributes = @()
foreach ($attribute in ($info.Attributes -split ',')) {

@ -8,6 +8,7 @@
Function New-TempFile {
Param ([string]$path, [string]$prefix, [string]$suffix, [string]$type, [bool]$checkmode)
$temppath = $null
$curerror = $null
$attempt = 0
# Since we don't know if the file already exists, we try 5 times with a random name
@ -26,13 +27,13 @@ Function New-TempFile {
}
} Catch {
$temppath = $null
$error = $_
$curerror = $_
}
} until (($null -ne $temppath) -or ($attempt -ge 5))
# If it fails 5 times, something is wrong and we have to report the details
if ($null -eq $temppath) {
$module.FailJson("No random temporary file worked in $attempt attempts. Error: $($error.Exception.Message)", $error)
$module.FailJson("No random temporary file worked in $attempt attempts. Error: $($curerror.Exception.Message)", $curerror)
}
return $temppath.ToString()

@ -12,7 +12,7 @@ $ErrorActionPreference = "Stop"
$osversion = [Environment]::OSVersion
$lowest_version = 10
if ($osversion.Version.Major -lt $lowest_version ) {
Fail-Json -obj $result -message "Sorry, this version of windows, $osversion, does not support Toast notifications. Toast notifications are available from version $lowest_version"
Fail-Json -obj $result -message "Sorry, this version of windows, $osversion, does not support Toast notifications. Toast notifications are available from version $lowest_version"
}
$stopwatch = [system.diagnostics.stopwatch]::startNew()
@ -43,27 +43,27 @@ $result = @{
# If no logged in users, there is no notifications service,
# and no-one to read the message, so exit but do not fail
# if there are no logged in users to notify.
if ((Get-Process -Name explorer -ErrorAction SilentlyContinue).Count -gt 0){
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipulation
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($title)) > $null
# TODO add subtitle
#Convert back to WinRT type
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = $tag
$toast.Group = $group
$toast.ExpirationTime = $expire_at
$toast.SuppressPopup = -not $popup
try {
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($msg)
if (-not $check_mode) {
@ -86,5 +86,5 @@ $stopwatch.Stop()
$result.time_taken = $stopwatch.Elapsed.TotalSeconds
$result.sent_localtime = $endsend_at.Trim()
Exit-Json -obj $result

@ -142,7 +142,7 @@ If ($ext -eq ".zip" -And $recurse -eq $false) {
}
If ($recurse) {
Get-ChildItem $dest -recurse | Where {$pcx_extensions -contains $_.extension} | % {
Get-ChildItem $dest -recurse | Where-Object {$pcx_extensions -contains $_.extension} | ForEach-Object {
Try {
Expand-Archive $_.FullName -OutputPath $dest -Force -WhatIf:$check_mode
} Catch {

@ -14,7 +14,7 @@ $LOGON32_PROVIDER_DEFAULT = 0
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
function Get-User($user) {
$adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
$adsi.Children | Where-Object {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
return
}
@ -27,7 +27,7 @@ function Get-UserFlag($user, $flag) {
}
}
function Set-UserFlag($user, $flag) {
function Set-UserFlag($user, $flag) {
$user.UserFlags = ($user.UserFlags[0] -BOR $flag)
}
@ -36,7 +36,7 @@ function Clear-UserFlag($user, $flag) {
}
function Get-Group($grp) {
$adsi.Children | where { $_.SchemaClassName -eq 'Group' -and $_.Name -eq $grp }
$adsi.Children | Where-Object { $_.SchemaClassName -eq 'Group' -and $_.Name -eq $grp }
return
}
@ -140,7 +140,7 @@ If ($null -ne $groups) {
ElseIf ($groups -isnot [System.Collections.IList]) {
Fail-Json $result "groups must be a string or array"
}
$groups = $groups | ForEach { ([string]$_).Trim() } | Where { $_ }
$groups = $groups | ForEach-Object { ([string]$_).Trim() } | Where-Object { $_ }
If ($null -eq $groups) {
$groups = @()
}
@ -219,7 +219,7 @@ If ($state -eq 'present') {
$user_obj.SetInfo()
}
If ($null -ne $groups) {
[string[]]$current_groups = $user_obj.Groups() | ForEach { $_.GetType().InvokeMember("Name", "GetProperty", $null, $_, $null) }
[string[]]$current_groups = $user_obj.Groups() | ForEach-Object { $_.GetType().InvokeMember("Name", "GetProperty", $null, $_, $null) }
If (($groups_action -eq "remove") -or ($groups_action -eq "replace")) {
ForEach ($grp in $current_groups) {
If ((($groups_action -eq "remove") -and ($groups -contains $grp)) -or (($groups_action -eq "replace") -and ($groups -notcontains $grp))) {

@ -230,7 +230,9 @@ if ($null -eq $path -and $null -eq $port -and $state -ne "drained") {
try {
$exclude_ips = [System.Net.Dns]::GetHostAddresses($exclude_host) | ForEach-Object { Write-Output $_.IPAddressToString }
$connection_info = $connection_info | Where-Object { $_ -notin $exclude_ips }
} catch {} # ignore invalid hostnames
} catch { # ignore invalid hostnames
Add-Warning -obj $result -message "Invalid hostname specified $exclude_host"
}
}
if ($connection_info.Count -eq 0) {

@ -81,7 +81,7 @@ Foreach ($group in $ACL.Audit)
#exit here if any existing rule matches defined rule, otherwise exit below
#with no matches
If (
($group | select -expand "*Rights") -eq $rights -and
($group | Select-Object -expand "*Rights") -eq $rights -and
$group.AuditFlags -eq $flags -and
$group.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]) -eq $SID -and
$group.InheritanceFlags -eq $inherit -and

@ -693,7 +693,7 @@ test_no_log - Invoked with:
hide: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
data: Oops this is secret: ********
custom: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
list:
list:
- VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
- ********word
- ********567

@ -48,14 +48,14 @@ Function Run-Process($executable, $arguments) {
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.UseShellExecute = $false
$proc.Start() | Out-Null # will always return $true for non shell-exec cases
$proc.Start() > $null # will always return $true for non shell-exec cases
$stdout = $stderr = [string] $null
[Ansible.Command.NativeUtil]::GetProcessOutput($proc.StandardOutput, $proc.StandardError, [ref] $stdout, [ref] $stderr) | Out-Null
$proc.WaitForExit() | Out-Null
[Ansible.Command.NativeUtil]::GetProcessOutput($proc.StandardOutput, $proc.StandardError, [ref] $stdout, [ref] $stderr) > $null
$proc.WaitForExit() > $null
$actual_args = $stdout.Substring(0, $stdout.Length - 2) -split "`r`n"
return $actual_args
}

@ -40,7 +40,6 @@ foreach ($entry in $output_dict.GetEnumerator()) {
$key = $entry.Name
$value = $entry.Value
$type = $value.GetType()
if ($value -is [Hashtable]) {
Assert-Equals -actual $key -expected "inner_hash_table"
foreach ($inner_hash in $value.GetEnumerator()) {

@ -18,7 +18,7 @@
$params = Parse-Args $args $true;
$x = $params.thisPropertyDoesNotExist
$params.thisPropertyDoesNotExist
$data = Get-Attr $params "data" "pong";

@ -1,175 +1,108 @@
examples/scripts/ConfigureRemotingForAnsible.ps1 PSAvoidTrailingWhitespace
examples/scripts/ConfigureRemotingForAnsible.ps1 PSAvoidUsingCmdletAliases
examples/scripts/ConfigureRemotingForAnsible.ps1 PSCustomUseLiteralPath
examples/scripts/upgrade_to_ps3.ps1 PSAvoidTrailingWhitespace
examples/scripts/upgrade_to_ps3.ps1 PSAvoidUsingWriteHost
examples/scripts/upgrade_to_ps3.ps1 PSCustomUseLiteralPath
examples/scripts/upgrade_to_ps3.ps1 PSUseApprovedVerbs
lib/ansible/executor/powershell/async_watchdog.ps1 PSCustomUseLiteralPath
lib/ansible/executor/powershell/async_wrapper.ps1 PSCustomUseLiteralPath
lib/ansible/executor/powershell/exec_wrapper.ps1 PSCustomUseLiteralPath
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CamelConversion.psm1 PSAvoidTrailingWhitespace
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 PSProvideCommentHelp # need to agree on best format for comment location
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 PSCustomUseLiteralPath
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 PSProvideCommentHelp
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSAvoidUsingWMICmdlet
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSCustomUseLiteralPath
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 PSAvoidTrailingWhitespace
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.SID.psm1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/async_status.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/setup.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/setup.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/setup.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/setup.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/setup.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_acl_inheritance.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_audit_rule.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey_config.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey_facts.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_chocolatey_facts.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey_source.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_copy.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_copy.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_credential.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_credential.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_credential.ps1 PSUsePSCredentialType # The Credential parameter is a custom .NET type
lib/ansible/modules/windows/win_disk_facts.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidGlobalVars
lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidUsingWMICmdlet
lib/ansible/modules/windows/win_dns_client.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_dns_client.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_dns_client.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_domain.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_domain.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidUsingWMICmdlet
lib/ansible/modules/windows/win_domain_controller.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_domain_controller.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_domain_controller.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_domain_group.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidUsingWMICmdlet
lib/ansible/modules/windows/win_domain_membership.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_domain_membership.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_domain_membership.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_dotnet_ngen.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_dsc.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_dsc.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_eventlog.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_feature.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_file_version.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_find.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingWMICmdlet
lib/ansible/modules/windows/win_firewall_rule.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_get_url.ps1 PSUsePSCredentialType # Credential param can take a base64 encoded string as well as a PSCredential
lib/ansible/modules/windows/win_hotfix.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_hotfix.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_hotfix.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_iis_virtualdirectory.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webapplication.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webapppool.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_iis_webapppool.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webbinding.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_iis_webbinding.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webbinding.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_iis_website.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_iis_website.ps1 PSAvoidUsingPositionalParameters
lib/ansible/modules/windows/win_iis_website.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_website.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_lineinfile.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_mapped_drive.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_msg.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_package.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_package.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_package.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_package.ps1 PSUsePSCredentialType
lib/ansible/modules/windows/win_pagefile.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_pagefile.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_pagefile.ps1 PSAvoidUsingPositionalParameters
lib/ansible/modules/windows/win_pagefile.ps1 PSAvoidUsingWMICmdlet
lib/ansible/modules/windows/win_pagefile.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_pagefile.ps1 PSUseSupportsShouldProcess
lib/ansible/modules/windows/win_pester.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_product_facts.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_product_facts.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 PSAvoidUsingInvokeExpression
lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_rds_cap.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_rds_cap.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_rds_rap.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_rds_rap.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_rds_settings.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_regedit.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_region.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_region.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_regmerge.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_regmerge.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_robocopy.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_route.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_route.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_scheduled_task_stat.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_scheduled_task_stat.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_scheduled_task_stat.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_security_policy.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_security_policy.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_security_policy.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_security_policy.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_share.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_shell.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_shell.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_shell.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_shortcut.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_snmp.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_stat.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_say.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_say.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_tempfile.ps1 PSAvoidAssignmentToAutomaticVariable
lib/ansible/modules/windows/win_toast.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_unzip.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_unzip.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_unzip.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_updates.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_uri.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_user.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_user.ps1 PSAvoidUsingCmdletAliases
lib/ansible/modules/windows/win_user_profile.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_wait_for.ps1 PSAvoidUsingEmptyCatchBlock
lib/ansible/modules/windows/win_wait_for.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_webpicmd.ps1 PSAvoidUsingInvokeExpression
lib/ansible/modules/windows/win_xml.ps1 PSCustomUseLiteralPath
test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/MyPSMU.psm1 PSUseApprovedVerbs
test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 PSAvoidUsingCmdletAliases
test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 PSCustomUseLiteralPath
test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.ps1 PSCustomUseLiteralPath
test/integration/targets/win_chocolatey_source/library/choco_source.ps1 PSCustomUseLiteralPath
test/integration/targets/win_csharp_utils/library/ansible_basic_tests.ps1 PSAvoidTrailingWhitespace
test/integration/targets/win_csharp_utils/library/ansible_basic_tests.ps1 PSCustomUseLiteralPath
test/integration/targets/win_csharp_utils/library/ansible_basic_tests.ps1 PSUseDeclaredVarsMoreThanAssignments # test setup requires vars to be set globally and not referenced in the same scope
test/integration/targets/win_csharp_utils/library/ansible_become_tests.ps1 PSCustomUseLiteralPath
test/integration/targets/win_exec_wrapper/library/test_fail.ps1 PSCustomUseLiteralPath
test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 PSUseApprovedVerbs
test/integration/targets/win_module_utils/library/argv_parser_test.ps1 PSAvoidTrailingWhitespace
test/integration/targets/win_module_utils/library/argv_parser_test.ps1 PSUseApprovedVerbs
test/integration/targets/win_module_utils/library/backup_file_test.ps1 PSCustomUseLiteralPath
test/integration/targets/win_module_utils/library/camel_conversion_test.ps1 PSUseDeclaredVarsMoreThanAssignments
test/integration/targets/win_module_utils/library/command_util_test.ps1 PSCustomUseLiteralPath
test/integration/targets/win_psmodule/files/setup_modules.ps1 PSCustomUseLiteralPath
test/integration/targets/win_ping/library/win_ping_strict_mode_error.ps1 PSUseDeclaredVarsMoreThanAssignments
test/integration/targets/win_reboot/templates/post_reboot.ps1 PSCustomUseLiteralPath
test/integration/targets/win_script/files/test_script.ps1 PSAvoidUsingWriteHost
test/integration/targets/win_script/files/test_script_creates_file.ps1 PSAvoidUsingCmdletAliases
test/integration/targets/win_script/files/test_script_removes_file.ps1 PSCustomUseLiteralPath
test/integration/targets/win_script/files/test_script_with_args.ps1 PSAvoidUsingWriteHost
test/integration/targets/win_script/files/test_script_with_splatting.ps1 PSAvoidUsingWriteHost
test/integration/targets/win_stat/library/test_symlink_file.ps1 PSCustomUseLiteralPath
test/integration/targets/win_user_right/library/test_get_right.ps1 PSCustomUseLiteralPath
test/runner/setup/windows-httptester.ps1 PSCustomUseLiteralPath
test/integration/targets/win_script/files/test_script.ps1 PSAvoidUsingWriteHost # Keep
test/integration/targets/win_script/files/test_script_with_args.ps1 PSAvoidUsingWriteHost # Keep
test/integration/targets/win_script/files/test_script_with_splatting.ps1 PSAvoidUsingWriteHost # Keep
lib/ansible/modules/windows/win_domain.ps1 PSAvoidUsingEmptyCatchBlock # Keep
lib/ansible/modules/windows/win_dsc.ps1 PSAvoidUsingEmptyCatchBlock # Keep
lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingEmptyCatchBlock # Keep
lib/ansible/modules/windows/win_region.ps1 PSAvoidUsingEmptyCatchBlock # Keep
lib/ansible/modules/windows/win_uri.ps1 PSAvoidUsingEmptyCatchBlock # Keep
lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingEmptyCatchBlock # Keep for now
lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidGlobalVars # New PR
lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidGlobalVars # New PR
lib/ansible/modules/windows/win_pagefile.ps1 PSUseDeclaredVarsMoreThanAssignments # New PR - bug test_path should be testPath
Loading…
Cancel
Save