allow ConfigureRemotingForAnsible.ps1 script to function from 'public' adapters
The current script fails on machines which have network interfaces designated as connected to "Public" networks (choices for network designation being Private, Domain, Public). This commit changes the script to NOT prevent winrm initialization when device is connected to a "Public" network.
This commit is contained in:
parent
97b99e4517
commit
be452c1b27
1 changed files with 11 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Configure a Windows host for remote management with Ansible
|
# Configure a Windows host for remote management with Ansible
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
#
|
#
|
||||||
# This script checks the current WinRM/PSRemoting configuration and makes the
|
# This script checks the current WinRM/PSRemoting configuration and makes the
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
Param (
|
Param (
|
||||||
[string]$SubjectName = $env:COMPUTERNAME,
|
[string]$SubjectName = $env:COMPUTERNAME,
|
||||||
[int]$CertValidityDays = 365,
|
[int]$CertValidityDays = 365,
|
||||||
|
[switch]$SkipNetworkProfileCheck,
|
||||||
$CreateSelfSignedCert = $true
|
$CreateSelfSignedCert = $true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,9 +98,15 @@ ElseIf ((Get-Service "WinRM").Status -ne "Running")
|
||||||
# WinRM should be running; check that we have a PS session config.
|
# WinRM should be running; check that we have a PS session config.
|
||||||
If (!(Get-PSSessionConfiguration -Verbose:$false) -or (!(Get-ChildItem WSMan:\localhost\Listener)))
|
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
|
Enable-PSRemoting -Force -ErrorAction Stop
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Else
|
Else
|
||||||
{
|
{
|
||||||
Write-Verbose "PS Remoting is already enabled."
|
Write-Verbose "PS Remoting is already enabled."
|
||||||
|
|
Loading…
Reference in a new issue