Permalink
Browse files

vagrant-winrm-config

  • Loading branch information...
1 parent a5b7541 commit 24e67565670da9820c3f3d407c8182e88f246e05 @ferventcoder committed Dec 4, 2013
Showing with 87 additions and 0 deletions.
  1. +61 −0 vagrant-winrm-config/tools/chocolateyInstall.ps1
  2. +26 −0 vagrant-winrm-config/vagrant-winrm-config.nuspec
@@ -0,0 +1,61 @@
+$packageName = 'vagrant-winrm-config'
+
+try {
+ #$toolsDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
+ #$WinRMConfiguration = Join-Path "$toolsDir" "setwinrmconfig.ps1"
+ #Start-ChocolateyProcessAsAdmin "& $WinRMConfiguration"
+
+ $WinRMSvcName = 'WinRM'
+ $FireWallSvcName = 'MpsSvc'
+ $FWSvcMode = $null
+
+ #Write-Host "Ensuring Required Services are Setup Correctly"
+ #Get-Service 'DcomLaunch','RpcSs','RpcEptMapper','BFE' | Set-Service -StartupType Automatic -PassThru | Start-Service
+
+ $FirewallSvc = Get-WmiObject Win32_Service | ? {$_.Name -eq $FireWallSvcName}
+ if ($FirewallSvc -ne $null) {
+ $FWSvcMode = $FirewallSvc.StartMode
+ if($FirewallSvc.StartMode -eq 'Disabled') {
+ Write-Host "Enabling Firewall Service to set WinRM config"
+ Set-Service $FireWallSvcName -StartupType Manual
+ }
+ if ($FirewallSvc.State -eq 'Stopped') {
+ Write-Host "Starting Windows Firewall Service"
+ Start-Service $FireWallSvcName
+ }
+ }
+
+ Write-Host 'Setting WinRM Service Configuration'
+ Set-Service $WinRMSvcName -StartupType Automatic
+ Start-Service $WinRMSvcName
+
+ &winrm "quickconfig" "-q"
+ &winrm "set" "winrm/config/winrs" "@{MaxMemoryPerShellMB=`"512`"}"
+ &winrm "set" "winrm/config" "@{MaxTimeoutms=`"1800000`"}"
+ &winrm "set" "winrm/config/service" "@{AllowUnencrypted=`"true`"}"
+ &winrm "set" "winrm/config/service/auth" "@{Basic=`"true`"}"
+
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+ $osVersion = [Environment]::OSVersion.Version
+ if ($osVersion -lt [Version]'6.1')
+ {
+ Write-Host "Ensuring WinRM Port 5985 is opened"
+ #&netsh "firewall" "add" "portopening" "TCP" "47001" "`"WinRM Port 47001`""
+ &netsh "firewall" "add" "portopening" "TCP" "5985" "`"WinRM Port 5985`""
+ Write-Host "Setting HTTP Transport for WinRM to Port 5985"
+ &winrm "set" "winrm/config/listener?Address=*+Transport=HTTP" "@{Port=`"5985`"}"
+ }
+
+ Write-Host 'Ensuring WinRM Service Startup Mode is Automatic'
+ Set-Service $WinRMSvcName -StartupType Automatic
+
+ if ($FWSvcMode -ne $null -and $FWSvcMode -eq 'Disabled') {
+ Write-Host "Stopping and disabling Firewall Service since it started that way"
+ Get-Service $FireWallSvcName | Stop-Service -PassThru | Set-Service -StartupType Disabled
+ }
+
+ Write-ChocolateySuccess "$packageName"
+} catch {
+ Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)"
+ throw
+}
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <id>vagrant-winrm-config</id>
+ <title>Vagrant WinRM Configuration</title>
+ <version>0.0.1</version>
+ <authors>Rob Reynolds</authors>
+ <owners>Rob Reynolds</owners>
+ <summary>Vagrant WinRM Configuration</summary>
+ <description>Vagrant WinRM Configuration
+
+ This sets up the configuration as described at https://github.com/WinRb/vagrant-windows/#winrm-configuration
+
+ NOTE: Please run this from an adminstrative command line as this has been known to fail attempting to put it into Start-ProcessAsAdministrator.
+ </description>
+ <projectUrl>https://github.com/ferventcoder/nugetpackages</projectUrl>
+ <tags>vagrant winrm configuration admin</tags>
+ <releaseNotes></releaseNotes>
+ <dependencies>
+ <dependency id="disableuac" version="0.0.2" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="tools\**" target="tools" />
+ </files>
+</package>

0 comments on commit 24e6756

Please sign in to comment.