Last active
August 29, 2015 14:17
-
-
Save mefellows/bde689b1f0722a16c8a8 to your computer and use it in GitHub Desktop.
Windows 2008r2 Elevated Provisioning Example
This file contains hidden or 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
{ | |
"builders": [{ | |
"type": "virtualbox-windows-ovf", | |
"name":"win2008updates", | |
"source_path": "/Users/mfellows/Downloads/packer-output-updates/virtualbox-win-2008-base.ovf", | |
"headless": false, | |
"boot_wait": "1m", | |
"winrm_username": "vagrant", | |
"winrm_password": "vagrant", | |
"winrm_wait_timeout": "5m", | |
"guest_additions_mode": "disable", | |
"shutdown_timeout": "2h", | |
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", | |
"vboxmanage": [ | |
["modifyvm", "{{.Name}}", "--memory", "2048"], | |
["modifyvm", "{{.Name}}", "--cpus", "1"] | |
] | |
}], | |
"provisioners": [ | |
{ | |
"type": "powershell", | |
"elevated_user": "vagrant", | |
"elevated_password": "vagrant", | |
"environment_vars":[ | |
"foo=bar", | |
"bat=bat" | |
], | |
"inline": [ | |
"echo $env:foo > c:\\foo.txt", | |
"echo $env:foo > ~/foo.txt", | |
"echo 'should have output foo before'", | |
"echo $env:bat > bat.txt", | |
"echo $env:bat > ~/bat.txt", | |
"echo 'should have output bat before'" | |
] | |
}, | |
{ | |
"type": "powershell", | |
"elevated_user": "vagrant", | |
"elevated_password": "vagrant", | |
"inline": [ | |
"$wc = New-Object System.Net.WebClient; $wc.DownloadFile(\"http://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows6.1-KB2819745-x64-MultiPkg.msu\", \"c:\\wmf4.msu\")", | |
"c:\\wmf4.msu /quiet" | |
] | |
}, | |
{ | |
"type":"restart-windows" | |
}, | |
{ | |
"type": "powershell", | |
"elevated_user": "vagrant", | |
"elevated_password": "vagrant", | |
"inline": [ | |
"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" | |
] | |
}, | |
{ | |
"type":"restart-windows" | |
}, | |
{ | |
"type": "powershell", | |
"elevated_user": "vagrant", | |
"elevated_password": "vagrant", | |
"environment_vars":[ | |
"foo=bar", | |
"bat=bat" | |
], | |
"inline": [ | |
"choco install netfx-4.5.2-devpack" | |
] | |
} | |
] | |
} |
This file contains hidden or 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
cmd.exe /c winrm quickconfig -q | |
cmd.exe /c winrm quickconfig '-transport:http' | |
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}' | |
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}' | |
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}' | |
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}' | |
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}' | |
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}' | |
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}' | |
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}' | |
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes | |
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" | |
cmd.exe /c net stop winrm | |
cmd.exe /c sc config winrm start= auto | |
cmd.exe /c net start winrm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
winrm-setup
(probably inAutounattend.xml file
) and then run Packer (with Packer Windows Plugins installed).The goal is to install .NET Devpack 4.5.2 using an elevated scheduled task.