summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorShachaf92 <shachaf.gold@gmail.com>2019-07-08 22:41:58 +0300
committerJordan Borean <jborean93@gmail.com>2019-07-09 05:41:58 +1000
commit7ddcaafee5d79c4fd0e7534466413bff43a78b6e (patch)
treee0ef883884c6031b445a731c3f5a7f7a1c831bec /examples
parent5689cc08cea71ce8bfbe15d74af4622d2913bcc1 (diff)
downloadansible-7ddcaafee5d79c4fd0e7534466413bff43a78b6e.tar.gz
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
Diffstat (limited to 'examples')
-rw-r--r--examples/scripts/ConfigureRemotingForAnsible.ps118
-rw-r--r--examples/scripts/upgrade_to_ps3.ps112
2 files changed, 15 insertions, 15 deletions
diff --git a/examples/scripts/ConfigureRemotingForAnsible.ps1 b/examples/scripts/ConfigureRemotingForAnsible.ps1
index 7e52a9b3e7..7e039bb415 100644
--- a/examples/scripts/ConfigureRemotingForAnsible.ps1
+++ b/examples/scripts/ConfigureRemotingForAnsible.ps1
@@ -93,7 +93,7 @@ Function New-LegacySelfSignedCert
[int]$ValidDays = 1095
)
- $hostnonFQDN = $env:computerName
+ $hostnonFQDN = $env:computerName
$hostFQDN = [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname
$SignatureAlgorithm = "SHA256"
@@ -170,7 +170,7 @@ Function Enable-GlobalHttpFirewallAccess
# try to find/enable the default rule first
$add_rule = $false
- $matching_rules = $fw.Rules | ? { $_.Name -eq "Windows Remote Management (HTTP-In)" }
+ $matching_rules = $fw.Rules | Where-Object { $_.Name -eq "Windows Remote Management (HTTP-In)" }
$rule = $null
If ($matching_rules) {
If ($matching_rules -isnot [Array]) {
@@ -180,7 +180,7 @@ Function Enable-GlobalHttpFirewallAccess
Else {
# try to find one with the All or Public profile first
Write-Verbose "Found multiple existing HTTP firewall rules..."
- $rule = $matching_rules | % { $_.Profiles -band 4 }[0]
+ $rule = $matching_rules | ForEach-Object { $_.Profiles -band 4 }[0]
If (-not $rule -or $rule -is [Array]) {
Write-Verbose "Editing an arbitrary single HTTP firewall rule (multiple existed)"
@@ -310,7 +310,7 @@ if ($token_value -ne 1) {
# Make sure there is a SSL listener.
$listeners = Get-ChildItem WSMan:\localhost\Listener
-If (!($listeners | Where {$_.Keys -like "TRANSPORT=HTTPS"}))
+If (!($listeners | Where-Object {$_.Keys -like "TRANSPORT=HTTPS"}))
{
# We cannot use New-SelfSignedCertificate on 2012R2 and earlier
$thumbprint = New-LegacySelfSignedCert -SubjectName $SubjectName -ValidDays $CertValidityDays
@@ -363,9 +363,9 @@ Else
# Check for basic authentication.
$basicAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "Basic"}
-If ($DisableBasicAuth)
+If ($DisableBasicAuth)
{
- If (($basicAuthSetting.Value) -eq $true)
+ If (($basicAuthSetting.Value) -eq $true)
{
Write-Verbose "Disabling basic auth support."
Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $false
@@ -375,8 +375,8 @@ If ($DisableBasicAuth)
{
Write-Verbose "Basic auth is already disabled."
}
-}
-Else
+}
+Else
{
If (($basicAuthSetting.Value) -eq $false)
{
@@ -394,7 +394,7 @@ Else
If ($EnableCredSSP)
{
# Check for CredSSP authentication
- $credsspAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where {$_.Name -eq "CredSSP"}
+ $credsspAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "CredSSP"}
If (($credsspAuthSetting.Value) -eq $false)
{
Write-Verbose "Enabling CredSSP auth support."
diff --git a/examples/scripts/upgrade_to_ps3.ps1 b/examples/scripts/upgrade_to_ps3.ps1
index c9f55267e4..359b835d5c 100644
--- a/examples/scripts/upgrade_to_ps3.ps1
+++ b/examples/scripts/upgrade_to_ps3.ps1
@@ -5,7 +5,7 @@
# some Ansible modules that may use Powershell 3 features, so systems may need
# to be upgraded. This may be used by a sample playbook. Refer to the windows
# documentation on docs.ansible.com for details.
-#
+#
# - hosts: windows
# tasks:
# - script: upgrade_to_ps3.ps1
@@ -20,7 +20,7 @@
if ($PSVersionTable.psversion.Major -ge 3)
{
- write-host "Powershell 3 Installed already; You don't need this"
+ Write-Output "Powershell 3 Installed already; You don't need this"
Exit
}
@@ -55,7 +55,7 @@ if (!(test-path $powershellpath))
# If the Operating System is above 6.2, then you already have PowerShell Version > 3
if ([Environment]::OSVersion.Version.Major -gt 6)
{
- write-host "OS is new; upgrade not needed."
+ Write-Output "OS is new; upgrade not needed."
Exit
}
@@ -67,11 +67,11 @@ $architecture = $ENV:PROCESSOR_ARCHITECTURE
if ($architecture -eq "AMD64")
{
$architecture = "x64"
-}
+}
else
{
- $architecture = "x86"
-}
+ $architecture = "x86"
+}
if ($osminor -eq 1)
{