summaryrefslogtreecommitdiff
path: root/examples/scripts
diff options
context:
space:
mode:
authornitzmahone <mdavis@ansible.com>2015-08-31 16:38:23 -0700
committernitzmahone <mdavis@ansible.com>2015-08-31 16:38:23 -0700
commit74694b2b0d50e4675944b6436649e33f02a0f5bc (patch)
treea70b90c98ad883b98166378040176dd0591c9129 /examples/scripts
parent9d193d8fb410e15f3fd331fa19c016c86ed29b23 (diff)
downloadansible-74694b2b0d50e4675944b6436649e33f02a0f5bc.tar.gz
moved WinRM setup script test after config
Diffstat (limited to 'examples/scripts')
-rw-r--r--examples/scripts/ConfigureRemotingForAnsible.ps147
1 files changed, 22 insertions, 25 deletions
diff --git a/examples/scripts/ConfigureRemotingForAnsible.ps1 b/examples/scripts/ConfigureRemotingForAnsible.ps1
index 1b45ce442b..a67ea8afb2 100644
--- a/examples/scripts/ConfigureRemotingForAnsible.ps1
+++ b/examples/scripts/ConfigureRemotingForAnsible.ps1
@@ -105,31 +105,6 @@ Else
Write-Verbose "PS Remoting is already enabled."
}
-
-# Test a remoting connection to localhost, which should work.
-$httpResult = Invoke-Command -ComputerName "localhost" -ScriptBlock {$env:COMPUTERNAME} -ErrorVariable httpError -ErrorAction SilentlyContinue
-$httpsOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
-
-$httpsResult = New-PSSession -UseSSL -ComputerName "localhost" -SessionOption $httpsOptions -ErrorVariable httpsError -ErrorAction SilentlyContinue
-
-If ($httpResult -and $httpsResult)
-{
- Write-Verbose "HTTP and HTTPS sessions are enabled."
-}
-ElseIf ($httpsResult -and !$httpResult)
-{
- Write-Verbose "HTTP sessions are disabled, HTTPS session are enabled."
-}
-ElseIf ($httpResult -and !$httpsResult)
-{
- Write-Verbose "HTTPS sessions are disabled, HTTP session are enabled."
-}
-Else
-{
- Throw "Unable to establish an HTTP or HTTPS remoting session."
-}
-
-
# Make sure there is a SSL listener.
$listeners = Get-ChildItem WSMan:\localhost\Listener
If (!($listeners | Where {$_.Keys -like "TRANSPORT=HTTPS"}))
@@ -194,5 +169,27 @@ Else
Write-Verbose "Firewall rule already exists to allow WinRM HTTPS."
}
+# Test a remoting connection to localhost, which should work.
+$httpResult = Invoke-Command -ComputerName "localhost" -ScriptBlock {$env:COMPUTERNAME} -ErrorVariable httpError -ErrorAction SilentlyContinue
+$httpsOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
+
+$httpsResult = New-PSSession -UseSSL -ComputerName "localhost" -SessionOption $httpsOptions -ErrorVariable httpsError -ErrorAction SilentlyContinue
+
+If ($httpResult -and $httpsResult)
+{
+ Write-Verbose "HTTP and HTTPS sessions are enabled."
+}
+ElseIf ($httpsResult -and !$httpResult)
+{
+ Write-Verbose "HTTP sessions are disabled, HTTPS session are enabled."
+}
+ElseIf ($httpResult -and !$httpsResult)
+{
+ Write-Verbose "HTTPS sessions are disabled, HTTP session are enabled."
+}
+Else
+{
+ Throw "Unable to establish an HTTP or HTTPS remoting session."
+}
Write-Verbose "PS Remoting has been successfully configured for Ansible."