Skip to content

Instantly share code, notes, and snippets.

@mwhooker
Created January 24, 2017 21:35
Show Gist options
  • Save mwhooker/2cb30aecbe2713b939afb82db2a15816 to your computer and use it in GitHub Desktop.
Save mwhooker/2cb30aecbe2713b939afb82db2a15816 to your computer and use it in GitHub Desktop.
<powershell>
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
net stop winrm
& c:\windows\system32\sc.exe config winrm start= auto
net start winrm
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
</powershell>
{
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"ami_name": "Win2016-PackerElevatedOutputBug",
"associate_public_ip_address": true,
"communicator": "winrm",
"force_deregister": true,
"instance_type": "t2.small",
"region": "us-east-1",
"secret_key": "{{user `aws_secret_key`}}",
"source_ami": "ami-b06249a7",
"type": "amazon-ebs",
"user_data_file": "4271.txt",
"windows_password_timeout": "20m",
"winrm_username": "Administrator"
}
],
"provisioners": [
{
"inline": [
"net user adminuser SuperS3cr3t /ADD",
"net localgroup Administrators adminuser /add"
],
"type": "powershell"
},
{
"elevated_password": "SuperS3cr3t",
"elevated_user": "adminuser",
"inline": "write-output 'Hello. This output should appear in the log during the packer run'",
"type": "powershell"
}
],
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment