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

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

View file

@ -20,7 +20,7 @@
if ($PSVersionTable.psversion.Major -ge 3)
{
write-host "Powershell 3 Installed already; You don't need this"
Write-Output "Powershell 3 Installed already; You don't need this"
Exit
}
@ -55,7 +55,7 @@ if (!(test-path $powershellpath))
# If the Operating System is above 6.2, then you already have PowerShell Version > 3
if ([Environment]::OSVersion.Version.Major -gt 6)
{
write-host "OS is new; upgrade not needed."
Write-Output "OS is new; upgrade not needed."
Exit
}

View file

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

View file

@ -212,9 +212,9 @@ if($gather_subset.Contains('distribution')) {
if($gather_subset.Contains('env')) {
$env_vars = @{ }
foreach ($item in Get-ChildItem Env:) {
$name = $item | select -ExpandProperty Name
$name = $item | Select-Object -ExpandProperty Name
# Powershell ConvertTo-Json fails if string ends with \
$value = ($item | select -ExpandProperty Value).TrimEnd("\")
$value = ($item | Select-Object -ExpandProperty Value).TrimEnd("\")
$env_vars.Add($name, $value)
}
@ -226,7 +226,7 @@ if($gather_subset.Contains('env')) {
if($gather_subset.Contains('facter')) {
# See if Facter is on the System Path
Try {
$facter_exe = Get-Command facter -ErrorAction Stop
Get-Command facter -ErrorAction Stop > $null
$facter_installed = $true
} Catch {
$facter_installed = $false
@ -234,7 +234,7 @@ if($gather_subset.Contains('facter')) {
# Get JSON from Facter, and parse it out.
if ($facter_installed) {
&facter -j | Tee-Object -Variable facter_output | Out-Null
&facter -j | Tee-Object -Variable facter_output > $null
$facts = "$facter_output" | ConvertFrom-Json
ForEach($fact in $facts.PSObject.Properties) {
$fact_name = $fact.Name
@ -246,7 +246,7 @@ if($gather_subset.Contains('facter')) {
if($gather_subset.Contains('interfaces')) {
$netcfg = Get-LazyCimInstance Win32_NetworkAdapterConfiguration
$ActiveNetcfg = @()
$ActiveNetcfg += $netcfg | where {$_.ipaddress -ne $null}
$ActiveNetcfg += $netcfg | Where-Object {$_.ipaddress -ne $null}
$namespaces = Get-LazyCimInstance __Namespace -namespace root
if ($namespaces | Where-Object { $_.Name -eq "StandardCimv" }) {
@ -412,7 +412,7 @@ if($gather_subset.Contains('windows_domain')) {
if($gather_subset.Contains('winrm')) {
$winrm_https_listener_parent_paths = Get-ChildItem -Path WSMan:\localhost\Listener -Recurse -ErrorAction SilentlyContinue | `
Where-Object {$_.PSChildName -eq "Transport" -and $_.Value -eq "HTTPS"} | select PSParentPath
Where-Object {$_.PSChildName -eq "Transport" -and $_.Value -eq "HTTPS"} | Select-Object PSParentPath
if ($winrm_https_listener_parent_paths -isnot [array]) {
$winrm_https_listener_parent_paths = @($winrm_https_listener_parent_paths)
}
@ -429,14 +429,16 @@ if($gather_subset.Contains('winrm')) {
$winrm_cert_thumbprints = @()
foreach ($https_listener in $https_listeners) {
$winrm_cert_thumbprints += $https_listener | where {$_.Name -EQ "CertificateThumbprint" } | select Value
$winrm_cert_thumbprints += $https_listener | Where-Object {$_.Name -EQ "CertificateThumbprint" } | Select-Object Value
}
$winrm_cert_expiry = @()
foreach ($winrm_cert_thumbprint in $winrm_cert_thumbprints) {
Try {
$winrm_cert_expiry += Get-ChildItem -Path Cert:\LocalMachine\My | where Thumbprint -EQ $winrm_cert_thumbprint.Value.ToString().ToUpper() | select NotAfter
} Catch {}
$winrm_cert_expiry += Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object Thumbprint -EQ $winrm_cert_thumbprint.Value.ToString().ToUpper() | Select-Object NotAfter
} Catch {
Add-Warning -obj $result -message "Error during certificate expiration retrieval: $($_.Exception.Message)"
}
}
$winrm_cert_expirations = $winrm_cert_expiry | Sort-Object NotAfter

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
$files = Get-AnsibleParam -obj $params -name "files" -type "list"
$directories = Get-AnsibleParam -obj $params -name "directories" -type "list"
$symlinks = Get-AnsibleParam -obj $params -name "symlinks" -type "list"
$result = @{
changed = $false

View file

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

View file

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

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
$retry_count = 0
While(-not $di.Attached -and $retry_count -lt 5) {
Sleep -Seconds 1 | Out-Null
Start-Sleep -Seconds 1 > $null
$di = $di | Get-DiskImage
$retry_count++
}
@ -70,7 +70,7 @@ ElseIf($state -eq "absent") {
If($di.Attached) {
$result.changed = $true
If(-not $check_mode) {
Dismount-DiskImage $image_path | Out-Null
Dismount-DiskImage $image_path > $null
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -254,7 +254,7 @@ Function Get-FileStat($file) {
} elseif ($file.PSIsContainer) {
$isdir = $true
$share_info = Get-WmiObject -Class Win32_Share -Filter "Path='$($file.Fullname -replace '\\', '\\')'"
$share_info = Get-CIMInstance -Class Win32_Share -Filter "Path='$($file.Fullname -replace '\\', '\\')'"
if ($null -ne $share_info) {
$isshared = $true
$file_stat.sharename = $share_info.Name
@ -266,8 +266,7 @@ Function Get-FileStat($file) {
try {
$dir_files = $file.EnumerateFiles("*", [System.IO.SearchOption]::AllDirectories)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
$size = 0
foreach ($dir_file in $dir_files) {
$size += $dir_file.Length
@ -304,7 +303,6 @@ Function Get-FilesInFolder($path) {
$dir_files = $dir.EnumerateFileSystemInfos("*", [System.IO.SearchOption]::TopDirectoryOnly)
} catch [System.IO.DirectoryNotFoundException] { # Broken ReparsePoint/Symlink, cannot enumerate
} catch [System.UnauthorizedAccessException] {} # No ListDirectory permissions, Get-ChildItem ignored this
foreach ($item in $dir_files) {
if ($item -is [System.IO.DirectoryInfo] -and $recurse) {
if (($item.Attributes -like '*ReparsePoint*' -and $follow) -or ($item.Attributes -notlike '*ReparsePoint*')) {

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

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
$metadata = @{
installed = $false

View file

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

View file

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

View file

@ -39,7 +39,7 @@ Function Add-Route {
if (!($Route)){
try {
# Find Interface Index
$InterfaceIndex = Find-NetRoute -RemoteIPAddress $Gateway | Select -First 1 -ExpandProperty InterfaceIndex
$InterfaceIndex = Find-NetRoute -RemoteIPAddress $Gateway | Select-Object -First 1 -ExpandProperty InterfaceIndex
# Add network route
New-NetRoute -DestinationPrefix $Destination -NextHop $Gateway -InterfaceIndex $InterfaceIndex -RouteMetric $Metric -ErrorAction Stop -WhatIf:$CheckMode|out-null

View file

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

View file

@ -27,7 +27,6 @@ if ($diff_mode) {
}
Function Run-SecEdit($arguments) {
$rc = $null
$stdout = $null
$stderr = $null
$log_path = [IO.Path]::GetTempFileName()

View file

@ -23,7 +23,7 @@ Function Cleanse-Stderr($raw_stderr) {
$matches["prenoise1"],
$matches["prenoise2"],
# filter out just the Error-tagged strings for now, and zap embedded CRLF chars
($clixml.Objs.ChildNodes | ? { $_.Name -eq 'S' } | ? { $_.S -eq 'Error' } | % { $_.'#text'.Replace('_x000D__x000A_','') } | Out-String),
($clixml.Objs.ChildNodes | Where-Object { $_.Name -eq 'S' } | Where-Object { $_.S -eq 'Error' } | ForEach-Object { $_.'#text'.Replace('_x000D__x000A_','') } | Out-String),
$matches["postnoise"]) | Out-String
return $merged_stderr.Trim()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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