From e0ff2bc392807ffb63894a3cb6377244f699ae5a Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Wed, 1 Mar 2017 07:30:48 -0800 Subject: [PATCH] modernize winrm setup and fix for 2008r2 Signed-off-by: Matt Wrock --- lib/kitchen/driver/ec2.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/kitchen/driver/ec2.rb b/lib/kitchen/driver/ec2.rb index d365a9e6..7bf293f5 100644 --- a/lib/kitchen/driver/ec2.rb +++ b/lib/kitchen/driver/ec2.rb @@ -567,13 +567,15 @@ def default_windows_user_data # Allow script execution Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force #PS Remoting and & winrm.cmd basic config - Enable-PSRemoting -Force -SkipNetworkProfileCheck + $enableArgs=@{Force=$true} + $command=Get-Command Enable-PSRemoting + if($command.Parameters.Keys -contains "skipnetworkprofilecheck"){ + $enableArgs.skipnetworkprofilecheck=$true + } + Enable-PSRemoting @enableArgs & winrm.cmd set winrm/config '@{MaxTimeoutms="1800000"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxShellsPerUser="50"}' >> $logfile - #Server settings - support username/password login - & winrm.cmd set winrm/config/service/auth '@{Basic="true"}' >> $logfile - & winrm.cmd set winrm/config/service '@{AllowUnencrypted="true"}' >> $logfile & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile #Firewall Config & netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any >> $logfile