facterdb 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,130 @@
1
+ {
2
+ "dmi": {
3
+ "manufacturer": "innotek GmbH",
4
+ "product": {
5
+ "name": "VirtualBox",
6
+ "serial_number": "0"
7
+ }
8
+ },
9
+ "env_windows_installdir": "C:\\Program Files\\Puppet Labs\\Puppet",
10
+ "facterversion": "3.1.5",
11
+ "fqdn": "foo.example.com",
12
+ "identity": {
13
+ "user": "FOO\\vagrant"
14
+ },
15
+ "is_virtual": true,
16
+ "kernel": "windows",
17
+ "kernelmajversion": "6.1",
18
+ "kernelrelease": "6.1.7600",
19
+ "kernelversion": "6.1.7600",
20
+ "memory": {
21
+ "system": {
22
+ "available": "321.22 MiB",
23
+ "available_bytes": 336826368,
24
+ "capacity": "68.62%",
25
+ "total": "1023.55 MiB",
26
+ "total_bytes": 1073274880,
27
+ "used": "702.33 MiB",
28
+ "used_bytes": 736448512
29
+ }
30
+ },
31
+ "networking": {
32
+ "fqdn": "foo",
33
+ "hostname": "foo",
34
+ "interfaces": {
35
+ "Local Area Connection": {
36
+ "bindings": [
37
+ {
38
+ "address": "10.0.2.15",
39
+ "netmask": "255.255.255.0",
40
+ "network": "10.0.2.0"
41
+ }
42
+ ],
43
+ "bindings6": [
44
+ {
45
+ "address": "fe80::700d:3fab:1d54:dc0d%11",
46
+ "netmask": "ffff:ffff:ffff:ffff::",
47
+ "network": "fe80::%11"
48
+ }
49
+ ],
50
+ "dhcp": "10.0.2.2",
51
+ "ip": "10.0.2.15",
52
+ "ip6": "fe80::700d:3fab:1d54:dc0d%11",
53
+ "mac": "08:00:27:67:C8:1B",
54
+ "mtu": 1500,
55
+ "netmask": "255.255.255.0",
56
+ "netmask6": "ffff:ffff:ffff:ffff::",
57
+ "network": "10.0.2.0",
58
+ "network6": "fe80::%11"
59
+ },
60
+ "Local Area Connection 3": {
61
+ "bindings": [
62
+ {
63
+ "address": "10.20.1.5",
64
+ "netmask": "255.255.255.0",
65
+ "network": "10.20.1.0"
66
+ }
67
+ ],
68
+ "bindings6": [
69
+ {
70
+ "address": "fe80::15ec:2eb0:42ca:d968%13",
71
+ "netmask": "ffff:ffff:ffff:ffff::",
72
+ "network": "fe80::%13"
73
+ }
74
+ ],
75
+ "ip": "10.20.1.5",
76
+ "ip6": "fe80::15ec:2eb0:42ca:d968%13",
77
+ "mac": "08:00:27:81:BB:CB",
78
+ "mtu": 1500,
79
+ "netmask": "255.255.255.0",
80
+ "netmask6": "ffff:ffff:ffff:ffff::",
81
+ "network": "10.20.1.0",
82
+ "network6": "fe80::%13"
83
+ }
84
+ },
85
+ "ip": "10.20.1.5",
86
+ "ip6": "fe80::15ec:2eb0:42ca:d968%13",
87
+ "mac": "08:00:27:81:BB:CB",
88
+ "mtu": 1500,
89
+ "netmask": "255.255.255.0",
90
+ "netmask6": "ffff:ffff:ffff:ffff::",
91
+ "network": "10.20.1.0",
92
+ "network6": "fe80::%13",
93
+ "primary": "Local Area Connection 3"
94
+ },
95
+ "os": {
96
+ "architecture": "x64",
97
+ "family": "windows",
98
+ "hardware": "x86_64",
99
+ "name": "windows",
100
+ "release": {
101
+ "full": "7",
102
+ "major": "7"
103
+ },
104
+ "windows": {
105
+ "system32": "C:\\Windows\\system32"
106
+ }
107
+ },
108
+ "path": "C:\\Program Files\\Puppet Labs\\Puppet\\puppet\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\facter\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\hiera\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\mcollective\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\sys\\ruby\\bin;C:\\Program Files\\Puppet Labs\\Puppet\\sys\\tools\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Git\\bin; ",
109
+ "processors": {
110
+ "count": 1,
111
+ "isa": "x64",
112
+ "models": [
113
+ "Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz"
114
+ ],
115
+ "physicalcount": 1
116
+ },
117
+ "ruby": {
118
+ "platform": "x64-mingw32",
119
+ "sitedir": "C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/2.1.0",
120
+ "version": "2.1.8"
121
+ },
122
+ "system_uptime": {
123
+ "days": 0,
124
+ "hours": 0,
125
+ "seconds": 177,
126
+ "uptime": "0:02 hours"
127
+ },
128
+ "timezone": "Coordinated Universal Time",
129
+ "virtual": "virtualbox"
130
+ }
data/facts/Vagrantfile CHANGED
@@ -189,4 +189,28 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
189
189
  host.vm.provision "shell", path: "get_facts.sh"
190
190
  host.vm.provision "shell", inline: "/sbin/shutdown -h now"
191
191
  end
192
+ config.vm.define "windows-7-x86_64" do |host|
193
+ host.vm.hostname = 'foo'
194
+ host.vm.box = "ferventcoder/win7pro-x64-nocm-lite"
195
+ host.vm.communicator = "winrm"
196
+ host.vm.guest = :windows
197
+ host.vm.network :private_network, :auto_network => true
198
+ host.vm.network "forwarded_port", guest: 22, host: 2200, id: "ssh", auto_correct: true
199
+ host.windows.set_work_network = true
200
+ host.vm.provision 'shell', path: "windows_get_facts.ps1"
201
+ #host.vm.provision 'shell', inline: "Stop-Computer -AsJob"
202
+ host.vm.provision 'shell', inline: "shutdown -s -f -c \"Fact Collection Complete\""
203
+ #host.vm.post_up_message = 'Note that windows machines do not automatically shutdown. You must run a \'vagrant destroy\' or \'vagrant halt\' to terminate/stop the build vm.'
204
+ end
205
+ config.vm.define "windows-2012r2-core-x86_64" do |host|
206
+ host.vm.hostname = 'foo'
207
+ host.vm.box = "windows-2012r2-core-x86_64"
208
+ host.vm.communicator = "winrm"
209
+ host.vm.guest = :windows
210
+ host.vm.network :private_network, :auto_network => true
211
+ host.vm.network "forwarded_port", guest: 22, host: 2200, id: "ssh", auto_correct: true
212
+ host.windows.set_work_network = true
213
+ host.vm.provision 'shell', path: "windows_get_facts.ps1"
214
+ host.vm.provision 'shell', inline: "shutdown -s -f -c \"Fact Collection Complete\""
215
+ end
192
216
  end
@@ -0,0 +1,11 @@
1
+ At the time of writing there are not suitable publicly available windows server
2
+ vagrant boxes that can be used to generate the facts.
3
+
4
+ In order to make fact collection reproducible, I have included packer templates
5
+ so boxes can be rebuilt.
6
+
7
+ run `packer build <file>.json`
8
+ followed by `vagrant add <boxname> <boxfile>`
9
+
10
+ Once the box is added a simple `vagrant up <windows_os_name>` will collect all the facts in the same manner as the unix based hosts.
11
+
@@ -0,0 +1,60 @@
1
+ param(
2
+ [array]$puppetAgentVersions = ('1.1.1','1.2.2','1.4.0'),
3
+ [string]$baseUrl = 'https://downloads.puppetlabs.com/windows',
4
+ [string]$fqdn = 'foo.example.com'
5
+ )
6
+
7
+ $PuppetInstallerPath = 'c:\vagrantshared\resources\installers'
8
+
9
+ # Make sure we have enough privs to install the things.
10
+ $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
11
+ if (! ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
12
+ Write-Host -ForegroundColor Red "You must run this script as an administrator."
13
+ Exit 1
14
+ }
15
+
16
+ # Create our tmp dir if it's not found
17
+ if (!(Test-Path $PuppetInstallerPath)) {
18
+ Write-Host "Creating folder `'$PuppetInstallerPath`'"
19
+ $null = New-Item -Path "$PuppetInstallerPath" -ItemType Directory
20
+ }
21
+
22
+ # Install each puppet version & collect facts.
23
+ foreach ($pupAgentVer in $puppetAgentVersions) {
24
+ $agentUrl = "$baseUrl/puppet-agent-$pupAgentVer-x64.msi"
25
+ $agentInstaller = Join-Path $PuppetInstallerPath "puppet-agent-$pupAgentVer-x64.msi"
26
+
27
+ write-Host "Downloading `'$agentUrl`' to `'$agentInstaller`'"
28
+ (New-Object Net.WebClient).DownloadFile("$agentUrl", "$agentInstaller")
29
+
30
+ #Install the actual agent, and
31
+ $install_args = @("/qn", "/norestart", "/i", "$agentInstaller", "PUPPET_AGENT_CERTNAME=$fqdn")
32
+ Write-Host "Installing Puppet. running msiexec.exe $install_args"
33
+ $agentProcess = Start-Process -FilePath msiexec.exe -ArgumentList $install_args -Wait -PassThru
34
+ if ($agentProcess.ExitCode -ne 0) {
35
+ Write-Host "Installer failed."
36
+ Exit 1
37
+ }
38
+ Write-Host "Puppet Agent $pupAgentVer successfully installed."
39
+
40
+ # Run facter
41
+ $facterBin = "C:\Program Files\Puppet Labs\Puppet\bin\facter.bat"
42
+ $facterVer = (&$facterBin facterversion).Substring(0,3)
43
+
44
+ $Os = (&$facterBin operatingsystem).ToLower()
45
+ $Osmaj = (&$facterBin operatingsystemmajrelease).ToLower()
46
+ $Hw = (&$facterBin hardwaremodel).ToLower()
47
+
48
+ # Supply a fqdn because vagrant windows only sets the short hostname. Without this
49
+ # the domain name will fallback to the hypervisor's domain.
50
+ $env:FACTER_fqdn = $fqdn
51
+
52
+ $facterArgs = @("-j")
53
+ $facterProcess = Start-Process -FilePath $facterBin -ArgumentList $facterArgs -Wait -PassThru -RedirectStandardOutput "C:\vagrant\$facterVer\$Os-$Osmaj-$Hw.facts"
54
+ if ($facterProcess.ExitCode -ne 0) {
55
+ Write-Host "Facter failed."
56
+ Exit 1
57
+ }
58
+ Write-Host "Facts collected for $Os-$Osmaj-$Hw with facter $facterVer"
59
+ }
60
+
@@ -0,0 +1,60 @@
1
+ {
2
+ "builders": [
3
+ {
4
+ "type": "virtualbox-iso",
5
+ "vboxmanage": [
6
+ [ "modifyvm", "{{.Name}}", "--natpf1", "guest_winrm,tcp,,55985,,5985" ],
7
+ [ "modifyvm", "{{.Name}}", "--memory", "4096" ],
8
+ [ "modifyvm", "{{.Name}}", "--vram", "48" ],
9
+ [ "modifyvm", "{{.Name}}", "--cpus", "2" ],
10
+ [ "modifyvm", "{{.Name}}", "--ioapic", "on" ]
11
+ ],
12
+ "guest_additions_mode": "{{ user `guest_additions_mode` }}",
13
+ "guest_additions_path": "C:/users/vagrant/VBoxGuestAdditions.iso",
14
+ "guest_os_type": "Windows2012_64",
15
+ "headless": "{{ user `headless` }}",
16
+ "iso_url": "{{ user `iso_url` }}",
17
+ "iso_checksum": "{{ user `iso_checksum` }}",
18
+ "iso_checksum_type": "{{ user `iso_checksum_type` }}",
19
+ "communicator": "winrm",
20
+ "winrm_username": "vagrant",
21
+ "winrm_password": "vagrant",
22
+ "winrm_timeout": "8h",
23
+ "shutdown_command": "a:/PackerShutdown.bat",
24
+ "shutdown_timeout": "30m",
25
+ "floppy_files": [
26
+ "answer_files/2012_r2{{user `core`}}/Autounattend.xml",
27
+ "scripts/oracle.cer",
28
+ "scripts/postunattend.xml",
29
+ "scripts/boxstarter.ps1",
30
+ "scripts/PackerShutdown.bat",
31
+ "scripts/package.ps1",
32
+ "scripts/SetupComplete-2012.cmd",
33
+ "scripts/Test-Command.ps1"
34
+ ]
35
+ }
36
+ ],
37
+
38
+ "provisioners": [
39
+ {
40
+ "type": "powershell",
41
+ "script": "scripts/provision.ps1"
42
+ }
43
+ ],
44
+ "post-processors": [
45
+ {
46
+ "type": "vagrant",
47
+ "keep_input_artifact": false,
48
+ "output": "windows2012r2core-{{.Provider}}.box",
49
+ "vagrantfile_template": "vagrant_templates/vagrantfile-windows.template"
50
+ }
51
+ ],
52
+ "variables": {
53
+ "core": "core",
54
+ "guest_additions_mode": "upload",
55
+ "headless": "false",
56
+ "iso_checksum": "849734f37346385dac2c101e4aacba4626bb141c",
57
+ "iso_checksum_type": "sha1",
58
+ "iso_url": "http://care.dlservice.microsoft.com/dl/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SSS_X64FREE_EN-US_DV9.ISO"
59
+ }
60
+ }
@@ -0,0 +1,146 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <unattend xmlns="urn:schemas-microsoft-com:unattend">
3
+ <settings pass="windowsPE">
4
+ <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
5
+ <SetupUILanguage>
6
+ <UILanguage>en-US</UILanguage>
7
+ </SetupUILanguage>
8
+ <InputLocale>en-US</InputLocale>
9
+ <SystemLocale>en-US</SystemLocale>
10
+ <UILanguage>en-US</UILanguage>
11
+ <UILanguageFallback>en-US</UILanguageFallback>
12
+ <UserLocale>en-US</UserLocale>
13
+ </component>
14
+ <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
15
+ <DiskConfiguration>
16
+ <Disk wcm:action="add">
17
+ <CreatePartitions>
18
+ <CreatePartition wcm:action="add">
19
+ <Type>Primary</Type>
20
+ <Order>1</Order>
21
+ <Size>350</Size>
22
+ </CreatePartition>
23
+ <CreatePartition wcm:action="add">
24
+ <Order>2</Order>
25
+ <Type>Primary</Type>
26
+ <Extend>true</Extend>
27
+ </CreatePartition>
28
+ </CreatePartitions>
29
+ <ModifyPartitions>
30
+ <ModifyPartition wcm:action="add">
31
+ <Active>true</Active>
32
+ <Format>NTFS</Format>
33
+ <Label>boot</Label>
34
+ <Order>1</Order>
35
+ <PartitionID>1</PartitionID>
36
+ </ModifyPartition>
37
+ <ModifyPartition wcm:action="add">
38
+ <Format>NTFS</Format>
39
+ <Label>Windows 2012 R2</Label>
40
+ <Letter>C</Letter>
41
+ <Order>2</Order>
42
+ <PartitionID>2</PartitionID>
43
+ </ModifyPartition>
44
+ </ModifyPartitions>
45
+ <DiskID>0</DiskID>
46
+ <WillWipeDisk>true</WillWipeDisk>
47
+ </Disk>
48
+ </DiskConfiguration>
49
+ <ImageInstall>
50
+ <OSImage>
51
+ <InstallFrom>
52
+ <MetaData wcm:action="add">
53
+ <Key>/IMAGE/NAME </Key>
54
+ <Value>Windows Server 2012 R2 SERVERSTANDARDCORE</Value>
55
+ </MetaData>
56
+ </InstallFrom>
57
+ <InstallTo>
58
+ <DiskID>0</DiskID>
59
+ <PartitionID>2</PartitionID>
60
+ </InstallTo>
61
+ </OSImage>
62
+ </ImageInstall>
63
+ <UserData>
64
+ <ProductKey>
65
+ <WillShowUI>OnError</WillShowUI>
66
+ </ProductKey>
67
+ <AcceptEula>true</AcceptEula>
68
+ <FullName>Vagrant</FullName>
69
+ <Organization>Vagrant</Organization>
70
+ </UserData>
71
+ </component>
72
+ </settings>
73
+ <settings pass="generalize">
74
+ <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
75
+ <SkipRearm>1</SkipRearm>
76
+ </component>
77
+ <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
78
+ <PersistAllDeviceInstalls>false</PersistAllDeviceInstalls>
79
+ <DoNotCleanUpNonPresentDevices>false</DoNotCleanUpNonPresentDevices>
80
+ </component>
81
+ </settings>
82
+ <settings pass="oobeSystem">
83
+ <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
84
+ <InputLocale>en-US</InputLocale>
85
+ <SystemLocale>en-US</SystemLocale>
86
+ <UILanguage>en-US</UILanguage>
87
+ <UserLocale>en-US</UserLocale>
88
+ </component>
89
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
90
+ <OOBE>
91
+ <HideEULAPage>true</HideEULAPage>
92
+ <HideLocalAccountScreen>true</HideLocalAccountScreen>
93
+ <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
94
+ <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
95
+ <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
96
+ <NetworkLocation>Home</NetworkLocation>
97
+ <ProtectYourPC>1</ProtectYourPC>
98
+ </OOBE>
99
+ <TimeZone>UTC</TimeZone>
100
+ <UserAccounts>
101
+ <AdministratorPassword>
102
+ <Value>vagrant</Value>
103
+ <PlainText>true</PlainText>
104
+ </AdministratorPassword>
105
+ <LocalAccounts>
106
+ <LocalAccount wcm:action="add">
107
+ <Password>
108
+ <Value>vagrant</Value>
109
+ <PlainText>true</PlainText>
110
+ </Password>
111
+ <Group>administrators</Group>
112
+ <DisplayName>Vagrant</DisplayName>
113
+ <Name>vagrant</Name>
114
+ <Description>Vagrant User</Description>
115
+ </LocalAccount>
116
+ </LocalAccounts>
117
+ </UserAccounts>
118
+ <AutoLogon>
119
+ <Password>
120
+ <Value>vagrant</Value>
121
+ <PlainText>true</PlainText>
122
+ </Password>
123
+ <Enabled>true</Enabled>
124
+ <Username>vagrant</Username>
125
+ </AutoLogon>
126
+ <FirstLogonCommands>
127
+ <SynchronousCommand wcm:action="add">
128
+ <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\boxstarter.ps1</CommandLine>
129
+ <Order>1</Order>
130
+ </SynchronousCommand>
131
+ </FirstLogonCommands>
132
+ </component>
133
+ </settings>
134
+ <settings pass="specialize">
135
+ <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
136
+ <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
137
+ </component>
138
+ <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
139
+ <IEHardenAdmin>false</IEHardenAdmin>
140
+ <IEHardenUser>false</IEHardenUser>
141
+ </component>
142
+ <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
143
+ <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
144
+ </component>
145
+ </settings>
146
+ </unattend>
@@ -0,0 +1,2 @@
1
+ netsh advfirewall firewall set rule name="WinRM-HTTP" new action=block
2
+ C:/windows/system32/sysprep/sysprep.exe /generalize /oobe /unattend:C:/Windows/Panther/Unattend/unattend.xml /quiet /shutdown
@@ -0,0 +1 @@
1
+ netsh advfirewall firewall set rule name="WinRM-HTTP" new action=allow
@@ -0,0 +1,11 @@
1
+ function Test-Command($cmdname)
2
+ {
3
+ try {
4
+ Get-Command -Name $cmdname
5
+ return $true
6
+ }
7
+ catch {
8
+ $global:error.RemoveAt(0)
9
+ return $false
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ $WinlogonPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
2
+ Remove-ItemProperty -Path $WinlogonPath -Name AutoAdminLogon
3
+ Remove-ItemProperty -Path $WinlogonPath -Name DefaultUserName
4
+
5
+ iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/mwrock/boxstarter/master/BuildScripts/bootstrapper.ps1'))
6
+ Get-Boxstarter -Force
7
+
8
+ $secpasswd = ConvertTo-SecureString "vagrant" -AsPlainText -Force
9
+ $cred = New-Object System.Management.Automation.PSCredential ("vagrant", $secpasswd)
10
+
11
+ Import-Module $env:appdata\boxstarter\boxstarter.chocolatey\boxstarter.chocolatey.psd1
12
+ Install-BoxstarterPackage -PackageName a:\package.ps1 -Credential $cred
@@ -0,0 +1,44 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ . a:\Test-Command.ps1
4
+
5
+ Enable-RemoteDesktop
6
+ netsh advfirewall firewall add rule name="Remote Desktop" dir=in localport=3389 protocol=TCP action=allow
7
+
8
+ Update-ExecutionPolicy -Policy Unrestricted
9
+
10
+ if (Test-Command -cmdname 'Uninstall-WindowsFeature') {
11
+ Write-BoxstarterMessage "Removing unused features..."
12
+ Remove-WindowsFeature -Name 'Powershell-ISE'
13
+ Get-WindowsFeature |
14
+ ? { $_.InstallState -eq 'Available' } |
15
+ Uninstall-WindowsFeature -Remove
16
+ }
17
+
18
+ #Install-WindowsUpdate -AcceptEula
19
+
20
+ Write-BoxstarterMessage "Removing page file"
21
+ $pageFileMemoryKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
22
+ Set-ItemProperty -Path $pageFileMemoryKey -Name PagingFiles -Value ""
23
+
24
+ if(Test-PendingReboot){ Invoke-Reboot }
25
+
26
+ Write-BoxstarterMessage "Setting up winrm"
27
+ netsh advfirewall firewall add rule name="WinRM-HTTP" dir=in localport=5985 protocol=TCP action=allow
28
+
29
+ $enableArgs=@{Force=$true}
30
+ try {
31
+ $command=Get-Command Enable-PSRemoting
32
+ if($command.Parameters.Keys -contains "skipnetworkprofilecheck"){
33
+ $enableArgs.skipnetworkprofilecheck=$true
34
+ }
35
+ }
36
+ catch {
37
+ $global:error.RemoveAt(0)
38
+ }
39
+ Enable-PSRemoting @enableArgs
40
+ Enable-WSManCredSSP -Force -Role Server
41
+ winrm set winrm/config/client/auth '@{Basic="true"}'
42
+ winrm set winrm/config/service/auth '@{Basic="true"}'
43
+ winrm set winrm/config/service '@{AllowUnencrypted="true"}'
44
+ Write-BoxstarterMessage "winrm setup complete"
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <unattend xmlns="urn:schemas-microsoft-com:unattend">
3
+ <settings pass="generalize">
4
+ <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5
+ <SkipRearm>1</SkipRearm>
6
+ </component>
7
+ <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
8
+ <PersistAllDeviceInstalls>false</PersistAllDeviceInstalls>
9
+ <DoNotCleanUpNonPresentDevices>false</DoNotCleanUpNonPresentDevices>
10
+ </component>
11
+ </settings>
12
+ <settings pass="oobeSystem">
13
+ <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
14
+ <InputLocale>en-US</InputLocale>
15
+ <SystemLocale>en-US</SystemLocale>
16
+ <UILanguage>en-US</UILanguage>
17
+ <UserLocale>en-US</UserLocale>
18
+ </component>
19
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
20
+ <OOBE>
21
+ <HideEULAPage>true</HideEULAPage>
22
+ <ProtectYourPC>1</ProtectYourPC>
23
+ <NetworkLocation>Home</NetworkLocation>
24
+ <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
25
+ </OOBE>
26
+ <TimeZone>UTC</TimeZone>
27
+ <UserAccounts>
28
+ <AdministratorPassword>
29
+ <Value>vagrant</Value>
30
+ <PlainText>true</PlainText>
31
+ </AdministratorPassword>
32
+ <LocalAccounts>
33
+ <LocalAccount wcm:action="add">
34
+ <Password>
35
+ <Value>vagrant</Value>
36
+ <PlainText>true</PlainText>
37
+ </Password>
38
+ <Group>administrators</Group>
39
+ <DisplayName>Vagrant</DisplayName>
40
+ <Name>vagrant</Name>
41
+ <Description>Vagrant User</Description>
42
+ </LocalAccount>
43
+ </LocalAccounts>
44
+ </UserAccounts>
45
+ </component>
46
+ </settings>
47
+ <settings pass="specialize">
48
+ </settings>
49
+ </unattend>
@@ -0,0 +1,86 @@
1
+ $ErrorActionPreference = "Stop"
2
+ . a:\Test-Command.ps1
3
+
4
+ Write-Host "Enabling file sharing firewale rules"
5
+ netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
6
+
7
+ if(Test-Path "C:\Users\vagrant\VBoxGuestAdditions.iso") {
8
+ Write-Host "Installing Guest Additions"
9
+ certutil -addstore -f "TrustedPublisher" A:\oracle.cer
10
+ cinst 7zip.commandline -y
11
+ Move-Item C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp
12
+ 7z x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox
13
+
14
+ Start-Process -FilePath "C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe" -ArgumentList "/S" -WorkingDirectory "C:\Windows\Temp\virtualbox" -Wait
15
+
16
+ Remove-Item C:\Windows\Temp\virtualbox -Recurse -Force
17
+ Remove-Item C:\Windows\Temp\VBoxGuestAdditions.iso -Force
18
+ }
19
+
20
+ Write-Host "Cleaning SxS..."
21
+ Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
22
+
23
+ @(
24
+ "$env:localappdata\Nuget",
25
+ "$env:localappdata\temp\*",
26
+ "$env:windir\logs",
27
+ "$env:windir\panther",
28
+ "$env:windir\temp\*",
29
+ "$env:windir\winsxs\manifestcache"
30
+ ) | % {
31
+ if(Test-Path $_) {
32
+ Write-Host "Removing $_"
33
+ try {
34
+ Takeown /d Y /R /f $_
35
+ Icacls $_ /GRANT:r administrators:F /T /c /q 2>&1 | Out-Null
36
+ Remove-Item $_ -Recurse -Force | Out-Null
37
+ } catch { $global:error.RemoveAt(0) }
38
+ }
39
+ }
40
+
41
+ Write-Host "defragging..."
42
+ if (Test-Command -cmdname 'Optimize-Volume') {
43
+ Optimize-Volume -DriveLetter C
44
+ } else {
45
+ Defrag.exe c: /H
46
+ }
47
+
48
+ Write-Host "0ing out empty space..."
49
+ $FilePath="c:\zero.tmp"
50
+ $Volume = Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'"
51
+ $ArraySize= 64kb
52
+ $SpaceToLeave= $Volume.Size * 0.05
53
+ $FileSize= $Volume.FreeSpace - $SpacetoLeave
54
+ $ZeroArray= new-object byte[]($ArraySize)
55
+
56
+ $Stream= [io.File]::OpenWrite($FilePath)
57
+ try {
58
+ $CurFileSize = 0
59
+ while($CurFileSize -lt $FileSize) {
60
+ $Stream.Write($ZeroArray,0, $ZeroArray.Length)
61
+ $CurFileSize +=$ZeroArray.Length
62
+ }
63
+ }
64
+ finally {
65
+ if($Stream) {
66
+ $Stream.Close()
67
+ }
68
+ }
69
+
70
+ Del $FilePath
71
+
72
+
73
+
74
+ Write-Host "copying auto unattend file"
75
+ mkdir C:\Windows\setup\scripts
76
+ copy-item a:\SetupComplete-2012.cmd C:\Windows\setup\scripts\SetupComplete.cmd -Force
77
+
78
+ mkdir C:\Windows\Panther\Unattend
79
+ copy-item a:\postunattend.xml C:\Windows\Panther\Unattend\unattend.xml
80
+
81
+ Write-Host "Recreate pagefile after sysprep"
82
+ $System = GWMI Win32_ComputerSystem -EnableAllPrivileges
83
+ if ($system -ne $null) {
84
+ $System.AutomaticManagedPagefile = $true
85
+ $System.Put()
86
+ }