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
This commit is contained in:
Shachaf92 2019-07-08 22:41:58 +03:00 committed by Jordan Borean
parent 5689cc08ce
commit 7ddcaafee5
49 changed files with 208 additions and 275 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -360,7 +360,7 @@ Function Get-PendingRebootStatus
Check if reboot is required, if so notify CA. Check if reboot is required, if so notify CA.
Function returns true if computer has a pending reboot 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 $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"} $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) 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 # this line must stay at the bottom to ensure all defined module parts are exported
Export-ModuleMember -Alias * -Function * -Cmdlet * Export-ModuleMember -Alias * -Function * -Cmdlet *

View file

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

View file

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

View file

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

View file

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

View file

@ -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 # used in query mode, contains the local files/directories/symlinks that are to be copied
$files = Get-AnsibleParam -obj $params -name "files" -type "list" $files = Get-AnsibleParam -obj $params -name "files" -type "list"
$directories = Get-AnsibleParam -obj $params -name "directories" -type "list" $directories = Get-AnsibleParam -obj $params -name "directories" -type "list"
$symlinks = Get-AnsibleParam -obj $params -name "symlinks" -type "list"
$result = @{ $result = @{
changed = $false changed = $false

View file

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

View file

@ -36,7 +36,6 @@ try {
} catch { } catch {
Fail-Json -obj $result -message "Failed to search the disks on the target: $($_.Exception.Message)" 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) { foreach ($disk in $disks) {
$disk_info = @{} $disk_info = @{}
$pdisk = Get-PhysicalDisk -ErrorAction SilentlyContinue | Where-Object { $pdisk = Get-PhysicalDisk -ErrorAction SilentlyContinue | Where-Object {

View file

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

View file

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

View file

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

View file

@ -10,6 +10,8 @@ Set-StrictMode -Version 2
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$ConfirmPreference = "None" $ConfirmPreference = "None"
$log_path = $null
Function Write-DebugLog { Function Write-DebugLog {
Param( Param(
[string]$msg [string]$msg
@ -21,7 +23,6 @@ Function Write-DebugLog {
$msg = "$date_str $msg" $msg = "$date_str $msg"
Write-Debug $msg Write-Debug $msg
if($log_path) { if($log_path) {
Add-Content $log_path $msg Add-Content $log_path $msg
} }
@ -39,17 +40,17 @@ Function Get-MissingFeatures {
} }
$missing_features = @($features | Where-Object InstallState -ne Installed) $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 return ,$missing_features # no, the comma's not a typo- allows us to return an empty array
} }
Function Ensure-FeatureInstallation { Function Ensure-FeatureInstallation {
# ensure RSAT-ADDS and AD-Domain-Services features are installed # 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 $feature_result = Install-WindowsFeature $required_features
$result.reboot_required = $feature_result.RestartNeeded $result.reboot_required = $feature_result.RestartNeeded
If(-not $feature_result.Success) { If(-not $feature_result.Success) {
Exit-Json -message ("Error installing AD-Domain-Services and RSAT-ADDS features: {0}" -f ($feature_result | Out-String)) 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 { Function Get-DomainControllerDomain {
Write-DebugLog "Checking for domain controller role and domain name" 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 $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 # 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 $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 $state = Get-AnsibleParam -obj $params -name "state" -validateset ("domain_controller", "member_server") -failifempty $result
$log_path = Get-AnsibleParam -obj $params -name "log_path" $log_path = Get-AnsibleParam -obj $params -name "log_path"
$_ansible_check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -default $false $_ansible_check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -default $false
$global:log_path = $log_path
Try { Try {
# ensure target OS support; < 2012 doesn't have cmdlet support for DC promotion # ensure target OS support; < 2012 doesn't have cmdlet support for DC promotion
If(-not (Get-Command Install-WindowsFeature -ErrorAction SilentlyContinue)) { If(-not (Get-Command Install-WindowsFeature -ErrorAction SilentlyContinue)) {
@ -208,7 +212,7 @@ Try {
if ($site_name) { if ($site_name) {
$install_params.SiteName = $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" Write-DebugLog "Installation complete, trying to start the Netlogon service"
# The Netlogon service is set to auto start but is not started. This is # 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 $local_admin_secure = $local_admin_password | ConvertTo-SecureString -AsPlainText -Force
Write-DebugLog "Uninstalling domain controller..." 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..." Write-DebugLog "Uninstallation complete, needs reboot..."
} }
default { throw ("invalid state {0}" -f $state) } default { throw ("invalid state {0}" -f $state) }
@ -268,4 +272,3 @@ Catch {
Throw Throw
} }

View file

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

View file

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

View file

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

View file

@ -48,11 +48,11 @@ namespace Ansible.Command {
[DllImport("kernel32.dll", EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode, SetLastError = true)] [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); 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)] [DllImport("kernel32.dll", EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, public static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess,
int dwShareMode, IntPtr SecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); 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); SafeFileHandle directoryHandle = CreateFile(symlink.FullName, 0, 2, System.IntPtr.Zero, CREATION_DISPOSITION_OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, System.IntPtr.Zero);
if(directoryHandle.IsInvalid) if(directoryHandle.IsInvalid)
throw new Win32Exception(Marshal.GetLastWin32Error()); throw new Win32Exception(Marshal.GetLastWin32Error());
@ -63,9 +63,9 @@ namespace Ansible.Command {
if (size<0) 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 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] == '\\') if (path[0] == '\\' && path[1] == '\\' && path[2] == '?' && path[3] == '\\')
return path.ToString().Substring(4); return path.ToString().Substring(4);
else else
return path.ToString(); return path.ToString();
} }
} }
} }
@ -177,7 +177,7 @@ Function Assert-Size($info) {
$size_pattern = '^(-?\d+)(b|k|m|g|t)?$' $size_pattern = '^(-?\d+)(b|k|m|g|t)?$'
$match = $size -match $size_pattern $match = $size -match $size_pattern
if ($match) { if ($match) {
[int]$specified_size = $matches[1] [int]$specified_size = $matches[1]
if ($null -eq $matches[2]) { if ($null -eq $matches[2]) {
$chosen_byte = 'b' $chosen_byte = 'b'
} else { } else {
@ -254,20 +254,19 @@ Function Get-FileStat($file) {
} elseif ($file.PSIsContainer) { } elseif ($file.PSIsContainer) {
$isdir = $true $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) { if ($null -ne $share_info) {
$isshared = $true $isshared = $true
$file_stat.sharename = $share_info.Name $file_stat.sharename = $share_info.Name
} }
# only get the size of a directory if there are files (not directories) inside the folder # 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 # Get-ChildItem -LiteralPath does not work properly on older OS', use .NET instead
$dir_files = @() $dir_files = @()
try { try {
$dir_files = $file.EnumerateFiles("*", [System.IO.SearchOption]::AllDirectories) $dir_files = $file.EnumerateFiles("*", [System.IO.SearchOption]::AllDirectories)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate } 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 $size = 0
foreach ($dir_file in $dir_files) { foreach ($dir_file in $dir_files) {
$size += $dir_file.Length $size += $dir_file.Length
@ -304,7 +303,6 @@ Function Get-FilesInFolder($path) {
$dir_files = $dir.EnumerateFileSystemInfos("*", [System.IO.SearchOption]::TopDirectoryOnly) $dir_files = $dir.EnumerateFileSystemInfos("*", [System.IO.SearchOption]::TopDirectoryOnly)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate } 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
foreach ($item in $dir_files) { foreach ($item in $dir_files) {
if ($item -is [System.IO.DirectoryInfo] -and $recurse) { if ($item -is [System.IO.DirectoryInfo] -and $recurse) {
if (($item.Attributes -like '*ReparsePoint*' -and $follow) -or ($item.Attributes -notlike '*ReparsePoint*')) { 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 $result.examined = $new_examined
if ($info -ne $false) { if ($info -ne $false) {
$files = $result.Files $files = $result.Files
$files += $info $files += $info
$new_matched = $result.matched + 1 $new_matched = $result.matched + 1

View file

@ -49,7 +49,7 @@ Function Extract-MSU($msu) {
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Fail-Json $result "failed to run expand.exe $($expand_args): RC = $LASTEXITCODE" Fail-Json $result "failed to run expand.exe $($expand_args): RC = $LASTEXITCODE"
} }
return $output_path 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" 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 [xml]$xml = Get-Content -Path $metadata_path.FullName
$cab_source_filename = $xml.unattend.servicing.package.source.GetAttribute("location") $cab_source_filename = $xml.unattend.servicing.package.source.GetAttribute("location")
$cab_source_filename = Split-Path -Path $cab_source_filename -Leaf $cab_source_filename = Split-Path -Path $cab_source_filename -Leaf
$cab_file = Join-Path -Path $extract_path -ChildPath $cab_source_filename $cab_file = Join-Path -Path $extract_path -ChildPath $cab_source_filename

View file

@ -169,7 +169,7 @@ Function Convert-ToPropertyValue($pool, $attribute_key, $attribute_value) {
# Ensure WebAdministration module is loaded # Ensure WebAdministration module is loaded
if ($null -eq (Get-Module -Name "WebAdministration" -ErrorAction SilentlyContinue)) { if ($null -eq (Get-Module -Name "WebAdministration" -ErrorAction SilentlyContinue)) {
Import-Module WebAdministration 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 Add-Type -Path $web_admin_dll_path
} }

View file

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

View file

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

View file

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

View file

@ -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 # will get some metadata about the program we are trying to install or remove
$metadata = @{ $metadata = @{
installed = $false installed = $false
@ -327,7 +327,7 @@ if ($state -eq "absent") {
if ($program_metadata.msi -eq $true) { if ($program_metadata.msi -eq $true) {
# we are uninstalling an msi # we are uninstalling an msi
if ( -Not $log_path ) { if ( -Not $log_path ) {
$temp_path = [System.IO.Path]::GetTempPath() $temp_path = [System.IO.Path]::GetTempPath()
$log_file = [System.IO.Path]::GetRandomFileName() $log_file = [System.IO.Path]::GetRandomFileName()
$log_path = Join-Path -Path $temp_path -ChildPath $log_file $log_path = Join-Path -Path $temp_path -ChildPath $log_file
@ -421,7 +421,7 @@ if ($state -eq "absent") {
if ($program_metadata.msi -eq $true) { if ($program_metadata.msi -eq $true) {
# we are installing an msi # we are installing an msi
if ( -Not $log_path ) { if ( -Not $log_path ) {
$temp_path = [System.IO.Path]::GetTempPath() $temp_path = [System.IO.Path]::GetTempPath()
$log_file = [System.IO.Path]::GetRandomFileName() $log_file = [System.IO.Path]::GetRandomFileName()
$log_path = Join-Path -Path $temp_path -ChildPath $log_file $log_path = Join-Path -Path $temp_path -ChildPath $log_file

View file

@ -9,12 +9,12 @@
Function Remove-Pagefile($path, $whatif) 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) 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) { if ($removeAll) {
$currentPageFiles = Get-WmiObject Win32_PageFileSetting $currentPageFiles = Get-CIMInstance Win32_PageFileSetting
if ($null -ne $currentPageFiles) { if ($null -ne $currentPageFiles) {
$currentPageFiles | Remove-WmiObject -WhatIf:$check_mode | Out-Null $currentPageFiles | Remove-CIMInstance -WhatIf:$check_mode > $null
$result.changed = $true $result.changed = $true
} }
} }
if ($null -ne $automatic) { if ($null -ne $automatic) {
# change autmoatic managed pagefile # change autmoatic managed pagefile
try { try {
$computerSystem = Get-WmiObject -Class win32_computersystem -EnableAllPrivileges $computerSystem = Get-CIMInstance -Class win32_computersystem
} catch { } catch {
Fail-Json $result "Failed to query WMI computer system object $($_.Exception.Message)" Fail-Json $result "Failed to query WMI computer system object $($_.Exception.Message)"
} }
if ($computerSystem.AutomaticManagedPagefile -ne $automatic) { if ($computerSystem.AutomaticManagedPagefile -ne $automatic) {
$computerSystem.AutomaticManagedPagefile = $automatic
if (-not $check_mode) { if (-not $check_mode) {
try { try {
$computerSystem.Put() | Out-Null $computerSystem | Set-CimInstance -Property @{automaticmanagedpagefile="$automatic"} > $null
} catch { } catch {
Fail-Json $result "Failed to set AutomaticManagedPagefile $($_.Exception.Message)" Fail-Json $result "Failed to set AutomaticManagedPagefile $($_.Exception.Message)"
} }
@ -91,7 +90,7 @@ if ($state -eq "absent") {
} }
# Make sure drive is accessible # 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" Fail-Json $result "Unable to access '${drive}:' drive"
} }
@ -100,15 +99,13 @@ if ($state -eq "absent") {
# Set pagefile # Set pagefile
if ($null -eq $curPagefile) { if ($null -eq $curPagefile) {
try { 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 { } catch {
Fail-Json $result "Failed to create pagefile $($_.Exception.Message)" Fail-Json $result "Failed to create pagefile $($_.Exception.Message)"
} }
if (-not ($systemManaged -or $check_mode)) { if (-not ($systemManaged -or $check_mode)) {
$pagefile.InitialSize = $initialSize
$pagefile.MaximumSize = $maximumSize
try { try {
$pagefile.Put() | out-null $pagefile | Set-CimInstance -Property @{ InitialSize = $initialSize; MaximumSize = $maximumSize}
} catch { } catch {
$originalExceptionMessage = $($_.Exception.Message) $originalExceptionMessage = $($_.Exception.Message)
# Try workaround before failing # Try workaround before failing
@ -124,7 +121,7 @@ if ($state -eq "absent") {
} }
$pagingFilesValues += "$fullPath $initialSize $maximumSize" $pagingFilesValues += "$fullPath $initialSize $maximumSize"
try { 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 { } catch {
Fail-Json $result "Failed to set pagefile settings to the registry for workaround $($_.Exception.Message) Original exception: $originalExceptionMessage" 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 }else
{ {
$CurPageFileSystemManaged = (Get-CimInstance -ClassName win32_Pagefile -Property 'System' -Filter "name='$($fullPath.Replace('\','\\'))'").System $CurPageFileSystemManaged = (Get-CimInstance -ClassName win32_Pagefile -Property 'System' -Filter "name='$($fullPath.Replace('\','\\'))'").System
if ((-not $check_mode) -and if ((-not $check_mode) -and
-not ($systemManaged -or $CurPageFileSystemManaged) -and -not ($systemManaged -or $CurPageFileSystemManaged) -and
( ($curPagefile.InitialSize -ne $initialSize) -or ( ($curPagefile.InitialSize -ne $initialSize) -or
($curPagefile.maximumSize -ne $maximumSize))) ($curPagefile.maximumSize -ne $maximumSize)))
{ {
$curPagefile.InitialSize = $initialSize $curPagefile.InitialSize = $initialSize
@ -158,7 +155,7 @@ if ($state -eq "absent") {
} }
$pagingFilesValues += "$fullPath $initialSize $maximumSize" $pagingFilesValues += "$fullPath $initialSize $maximumSize"
try { 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 { } catch {
Fail-Json $result "Failed to set pagefile settings to the registry for workaround $($_.Exception.Message) Original exception: $originalExceptionMessage" 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) { if ($null -eq $drive) {
try { try {
$pagefiles = Get-WmiObject Win32_PageFileSetting $pagefiles = Get-CIMInstance Win32_PageFileSetting
} catch { } catch {
Fail-Json $result "Failed to query all pagefiles $($_.Exception.Message)" Fail-Json $result "Failed to query all pagefiles $($_.Exception.Message)"
} }
@ -192,12 +189,12 @@ if ($state -eq "absent") {
caption = $currentPagefile.Caption caption = $currentPagefile.Caption
description = $currentPagefile.Description description = $currentPagefile.Description
} }
$result.pagefiles += $currentPagefileObject $result.pagefiles += ,$currentPagefileObject
} }
# Get automatic managed pagefile state # Get automatic managed pagefile state
try { try {
$result.automatic_managed_pagefiles = (Get-WmiObject -Class win32_computersystem).AutomaticManagedPagefile $result.automatic_managed_pagefiles = (Get-CIMInstance -Class win32_computersystem).AutomaticManagedPagefile
} catch { } catch {
Fail-Json $result "Failed to query automatic managed pagefile state $($_.Exception.Message)" Fail-Json $result "Failed to query automatic managed pagefile state $($_.Exception.Message)"
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -39,13 +39,13 @@ Function Add-Route {
if (!($Route)){ if (!($Route)){
try { try {
# Find Interface Index # 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 # 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.changed = $true
$result.output = "Route added" $result.output = "Route added"
} }
catch { catch {
$ErrorMessage = $_.Exception.Message $ErrorMessage = $_.Exception.Message
@ -55,7 +55,7 @@ Function Add-Route {
else { else {
$result.output = "Static route already exists" $result.output = "Static route already exists"
} }
} }
Function Remove-Route { Function Remove-Route {
@ -69,7 +69,7 @@ Function Remove-Route {
if ($Route){ if ($Route){
try { 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.changed = $true
$result.output = "Route removed" $result.output = "Route removed"
} }
@ -84,7 +84,7 @@ Function Remove-Route {
} }
# Set gateway if null # Set gateway if null
if(!($gateway)){ if(!($gateway)){
$gateway = "0.0.0.0" $gateway = "0.0.0.0"
} }

View file

@ -42,7 +42,7 @@ $words = $null
if ($msg_file) { if ($msg_file) {
if (-not (Test-Path -Path $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.") $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 $words = Get-Content $msg_file | Out-String
} }
@ -53,7 +53,7 @@ if ($msg) {
if ($start_sound_path) { if ($start_sound_path) {
if (-not (Test-Path -Path $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.") $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) { if (-not $module.CheckMode) {
(new-object Media.SoundPlayer $start_sound_path).playSync() (new-object Media.SoundPlayer $start_sound_path).playSync()
} }
@ -84,7 +84,7 @@ if ($words) {
if ($end_sound_path) { if ($end_sound_path) {
if (-not (Test-Path -Path $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.") $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) { if (-not $module.CheckMode) {
(new-object Media.SoundPlayer $end_sound_path).playSync() (new-object Media.SoundPlayer $end_sound_path).playSync()
} }

View file

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

View file

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

View file

@ -23,7 +23,7 @@ Function Cleanse-Stderr($raw_stderr) {
$matches["prenoise1"], $matches["prenoise1"],
$matches["prenoise2"], $matches["prenoise2"],
# filter out just the Error-tagged strings for now, and zap embedded CRLF chars # 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 $matches["postnoise"]) | Out-String
return $merged_stderr.Trim() return $merged_stderr.Trim()
@ -119,7 +119,7 @@ try {
# TODO: decode CLIXML stderr output (and other streams?) # TODO: decode CLIXML stderr output (and other streams?)
$result.stdout = $command_result.stdout $result.stdout = $command_result.stdout
$result.stderr = Cleanse-Stderr $command_result.stderr $result.stderr = Cleanse-Stderr $command_result.stderr
$result.rc = $command_result.rc $result.rc = $command_result.rc
$end_datetime = [DateTime]::UtcNow $end_datetime = [DateTime]::UtcNow

View file

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

View file

@ -8,6 +8,7 @@
Function New-TempFile { Function New-TempFile {
Param ([string]$path, [string]$prefix, [string]$suffix, [string]$type, [bool]$checkmode) Param ([string]$path, [string]$prefix, [string]$suffix, [string]$type, [bool]$checkmode)
$temppath = $null $temppath = $null
$curerror = $null
$attempt = 0 $attempt = 0
# Since we don't know if the file already exists, we try 5 times with a random name # 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 { } Catch {
$temppath = $null $temppath = $null
$error = $_ $curerror = $_
} }
} until (($null -ne $temppath) -or ($attempt -ge 5)) } until (($null -ne $temppath) -or ($attempt -ge 5))
# If it fails 5 times, something is wrong and we have to report the details # If it fails 5 times, something is wrong and we have to report the details
if ($null -eq $temppath) { 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() return $temppath.ToString()

View file

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

View file

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

View file

@ -14,7 +14,7 @@ $LOGON32_PROVIDER_DEFAULT = 0
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME" $adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
function Get-User($user) { 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 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) $user.UserFlags = ($user.UserFlags[0] -BOR $flag)
} }
@ -36,7 +36,7 @@ function Clear-UserFlag($user, $flag) {
} }
function Get-Group($grp) { 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 return
} }
@ -140,7 +140,7 @@ If ($null -ne $groups) {
ElseIf ($groups -isnot [System.Collections.IList]) { ElseIf ($groups -isnot [System.Collections.IList]) {
Fail-Json $result "groups must be a string or array" 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) { If ($null -eq $groups) {
$groups = @() $groups = @()
} }
@ -219,7 +219,7 @@ If ($state -eq 'present') {
$user_obj.SetInfo() $user_obj.SetInfo()
} }
If ($null -ne $groups) { 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")) { If (($groups_action -eq "remove") -or ($groups_action -eq "replace")) {
ForEach ($grp in $current_groups) { ForEach ($grp in $current_groups) {
If ((($groups_action -eq "remove") -and ($groups -contains $grp)) -or (($groups_action -eq "replace") -and ($groups -notcontains $grp))) { If ((($groups_action -eq "remove") -and ($groups -contains $grp)) -or (($groups_action -eq "replace") -and ($groups -notcontains $grp))) {

View file

@ -230,7 +230,9 @@ if ($null -eq $path -and $null -eq $port -and $state -ne "drained") {
try { try {
$exclude_ips = [System.Net.Dns]::GetHostAddresses($exclude_host) | ForEach-Object { Write-Output $_.IPAddressToString } $exclude_ips = [System.Net.Dns]::GetHostAddresses($exclude_host) | ForEach-Object { Write-Output $_.IPAddressToString }
$connection_info = $connection_info | Where-Object { $_ -notin $exclude_ips } $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) { if ($connection_info.Count -eq 0) {

View file

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

View file

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

View file

@ -48,14 +48,14 @@ Function Run-Process($executable, $arguments) {
$psi.RedirectStandardOutput = $true $psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true $psi.RedirectStandardError = $true
$psi.UseShellExecute = $false $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 $stdout = $stderr = [string] $null
[Ansible.Command.NativeUtil]::GetProcessOutput($proc.StandardOutput, $proc.StandardError, [ref] $stdout, [ref] $stderr) | Out-Null [Ansible.Command.NativeUtil]::GetProcessOutput($proc.StandardOutput, $proc.StandardError, [ref] $stdout, [ref] $stderr) > $null
$proc.WaitForExit() | Out-Null $proc.WaitForExit() > $null
$actual_args = $stdout.Substring(0, $stdout.Length - 2) -split "`r`n" $actual_args = $stdout.Substring(0, $stdout.Length - 2) -split "`r`n"
return $actual_args return $actual_args
} }

View file

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

View file

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

View file

@ -1,175 +1,108 @@
examples/scripts/ConfigureRemotingForAnsible.ps1 PSAvoidTrailingWhitespace
examples/scripts/ConfigureRemotingForAnsible.ps1 PSAvoidUsingCmdletAliases
examples/scripts/ConfigureRemotingForAnsible.ps1 PSCustomUseLiteralPath 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 PSCustomUseLiteralPath
examples/scripts/upgrade_to_ps3.ps1 PSUseApprovedVerbs examples/scripts/upgrade_to_ps3.ps1 PSUseApprovedVerbs
lib/ansible/executor/powershell/async_watchdog.ps1 PSCustomUseLiteralPath lib/ansible/executor/powershell/async_watchdog.ps1 PSCustomUseLiteralPath
lib/ansible/executor/powershell/async_wrapper.ps1 PSCustomUseLiteralPath lib/ansible/executor/powershell/async_wrapper.ps1 PSCustomUseLiteralPath
lib/ansible/executor/powershell/exec_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.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 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.CommandUtil.psm1 PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 PSCustomUseLiteralPath 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.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 PSCustomUseLiteralPath
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSUseApprovedVerbs 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.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/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 PSCustomUseLiteralPath
lib/ansible/modules/windows/setup.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_acl_inheritance.ps1 PSAvoidTrailingWhitespace lib/ansible/modules/windows/win_acl_inheritance.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_audit_rule.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_audit_rule.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey.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_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_facts.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_chocolatey_source.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 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 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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_dns_client.ps1 PSUseApprovedVerbs 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.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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_domain_controller.ps1 PSUseApprovedVerbs 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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_domain_membership.ps1 PSUseApprovedVerbs 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_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_dsc.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_eventlog.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_eventlog.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_feature.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_feature.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_file_version.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_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_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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_hotfix.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_hotfix.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_iis_virtualdirectory.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_iis_virtualdirectory.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webapplication.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_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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_webbinding.ps1 PSUseApprovedVerbs 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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_iis_website.ps1 PSUseDeclaredVarsMoreThanAssignments
lib/ansible/modules/windows/win_lineinfile.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_lineinfile.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_mapped_drive.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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_package.ps1 PSUseApprovedVerbs 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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_pagefile.ps1 PSUseSupportsShouldProcess lib/ansible/modules/windows/win_pagefile.ps1 PSUseSupportsShouldProcess
lib/ansible/modules/windows/win_pester.ps1 PSCustomUseLiteralPath 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_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 PSAvoidUsingInvokeExpression
lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 PSCustomUseLiteralPath 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_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_rap.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_rds_settings.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_rds_settings.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_regedit.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_region.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_regmerge.ps1 PSAvoidTrailingWhitespace
lib/ansible/modules/windows/win_regmerge.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_regmerge.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_robocopy.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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_security_policy.ps1 PSUseApprovedVerbs 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_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_shell.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_shortcut.ps1 PSCustomUseLiteralPath lib/ansible/modules/windows/win_shortcut.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_snmp.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_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 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_unzip.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_unzip.ps1 PSUseApprovedVerbs
lib/ansible/modules/windows/win_updates.ps1 PSCustomUseLiteralPath 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_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_wait_for.ps1 PSCustomUseLiteralPath
lib/ansible/modules/windows/win_webpicmd.ps1 PSAvoidUsingInvokeExpression lib/ansible/modules/windows/win_webpicmd.ps1 PSAvoidUsingInvokeExpression
lib/ansible/modules/windows/win_xml.ps1 PSCustomUseLiteralPath 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/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_audit_rule/library/test_get_audit_rule.ps1 PSCustomUseLiteralPath
test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.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_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 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_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_csharp_utils/library/ansible_become_tests.ps1 PSCustomUseLiteralPath
test/integration/targets/win_exec_wrapper/library/test_fail.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_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/argv_parser_test.ps1 PSUseApprovedVerbs
test/integration/targets/win_module_utils/library/backup_file_test.ps1 PSCustomUseLiteralPath 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_module_utils/library/command_util_test.ps1 PSCustomUseLiteralPath
test/integration/targets/win_psmodule/files/setup_modules.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_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_creates_file.ps1 PSAvoidUsingCmdletAliases
test/integration/targets/win_script/files/test_script_removes_file.ps1 PSCustomUseLiteralPath 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_stat/library/test_symlink_file.ps1 PSCustomUseLiteralPath
test/integration/targets/win_user_right/library/test_get_right.ps1 PSCustomUseLiteralPath test/integration/targets/win_user_right/library/test_get_right.ps1 PSCustomUseLiteralPath
test/runner/setup/windows-httptester.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