summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
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)
{