forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ansible#12363 from breathe/devel
allow ConfigureRemotingForAnsible.ps1 script from public zone
- Loading branch information
Showing
2 changed files
with
33 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,13 @@ | |
# This script checks the current WinRM/PSRemoting configuration and makes the | ||
# necessary changes to allow Ansible to connect, authenticate and execute | ||
# PowerShell commands. | ||
# | ||
# | ||
# Set $VerbosePreference = "Continue" before running the script in order to | ||
# see the output messages. | ||
# Set $SkipNetworkProfileCheck to skip the network profile check. Without | ||
# specifying this the script will only run if the device's interfaces are in | ||
# DOMAIN or PRIVATE zones. Provide this switch if you want to enable winrm on | ||
# a device with an interface in PUBLIC zone. | ||
# | ||
# Written by Trond Hindenes <[email protected]> | ||
# Updated by Chris Church <[email protected]> | ||
|
@@ -19,6 +23,7 @@ | |
Param ( | ||
[string]$SubjectName = $env:COMPUTERNAME, | ||
[int]$CertValidityDays = 365, | ||
[switch]$SkipNetworkProfileCheck, | ||
$CreateSelfSignedCert = $true | ||
) | ||
|
||
|
@@ -28,7 +33,7 @@ Function New-LegacySelfSignedCert | |
[string]$SubjectName, | ||
[int]$ValidDays = 365 | ||
) | ||
|
||
$name = New-Object -COM "X509Enrollment.CX500DistinguishedName.1" | ||
$name.Encode("CN=$SubjectName", 0) | ||
|
||
|
@@ -96,8 +101,14 @@ ElseIf ((Get-Service "WinRM").Status -ne "Running") | |
# WinRM should be running; check that we have a PS session config. | ||
If (!(Get-PSSessionConfiguration -Verbose:$false) -or (!(Get-ChildItem WSMan:\localhost\Listener))) | ||
{ | ||
Write-Verbose "Enabling PS Remoting." | ||
if ($SkipNetworkProfileCheck) { | ||
Write-Verbose "Enabling PS Remoting without checking Network profile." | ||
Enable-PSRemoting -SkipNetworkProfileCheck -Force -ErrorAction Stop | ||
} | ||
else { | ||
Write-Verbose "Enabling PS Remoting" | ||
Enable-PSRemoting -Force -ErrorAction Stop | ||
} | ||
} | ||
Else | ||
{ | ||
|