vagrant-windows-sysprep 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c54e69feb971b2d5962fa047273c8e9f2e14c6046127f785cd76459d8436126c
4
- data.tar.gz: d04250e3e6792d9966469a8ec911ab70825b234ad83fbcc7b9511838b398dc07
3
+ metadata.gz: 6f81ac7681b191b71da857ec4bb21f13ac450682c6f62451a0b97285826e9666
4
+ data.tar.gz: f7c60e71d32341d7b56f91574e742b9e060141d2d97ea57121b20dd4b3391b02
5
5
  SHA512:
6
- metadata.gz: 668461a1986b312481767ec3dd107fc13e94ad8fb4c03a98d7a1ce8bae0ae5c806a984eec9165df6d407aa8c02eb82f8efec58c0192144c828516972a1600652
7
- data.tar.gz: '08d1f86777cd13c21133ec41b8d3497dc40c2dee54ef08e33c68f5de158a1fd895f4785434b3bf8fd1692b00af805d297047945c851d7f7f7bd595f854b398ef'
6
+ metadata.gz: e59ec1f3864b6ab68062c9af22ed17831e0e0b3ff040062d38670c3d2798e62dbe866d1d59d52cb491f0290bcbe66caf191e9f242f0310fa86a5cafc779c11ce
7
+ data.tar.gz: ecc4444e2044e49f4257b557dd3dd79da1facebda49889981d48e30887ddd986a2631fc8cbac6dbc2e430061dfe02d18a4924c6db38d902260ca214ccb904d19
@@ -1,5 +1,7 @@
1
1
  param(
2
- [string]$ComputerName = $null
2
+ [string]$ComputerName = $null,
3
+ [string]$Username = 'vagrant',
4
+ [string]$Password = 'vagrant'
3
5
  )
4
6
 
5
7
  Set-StrictMode -Version Latest
@@ -17,19 +19,92 @@ if (!$ComputerName) {
17
19
  }
18
20
 
19
21
  $unattendPath = "$PSScriptRoot\vagrant-windows-sysprep-unattend.xml"
22
+ $unattendPs1Path = "$PSScriptRoot\vagrant-windows-sysprep-unattend.ps1"
20
23
 
24
+ # NB doing an auto-logon after a sysprep has two effects:
25
+ # 1. make Windows 10 1809 not ask for an account creation (regardless of the
26
+ # value of SkipUserOOBE/SkipMachineOOBE).
27
+ # NB even when you disable the local accounts security questions with:
28
+ # # Windows 10 1803 started to require local account security questions but provided
29
+ # # no way to configure or skip those on sysprep, so we have to manually disable
30
+ # # that feature.
31
+ # # NB even with this windows stills asks for a Password Hint.
32
+ # # see https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/customize-oobe
33
+ # Write-Host 'Disabling the use of Security Questions for Local Accounts...'
34
+ # Set-ItemProperty `
35
+ # -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System `
36
+ # -Name NoLocalPasswordResetQuestions `
37
+ # -Value 1
38
+ # Windows will still ask for a password hint...
39
+ # 2. make vagrant be able to go through the stage (on Windows 10 1809):
40
+ # ==> default: Mounting SMB shared folders...
41
+ # default: /home/rgl/Projects/windows-2016-vagrant/example => /vagrant
21
42
  # NB there's a bug somewhere in windows sysprep machinery that prevents it from setting the
22
43
  # ComputerName when the name doesn't really change (like when you use config.vm.hostname),
23
44
  # it will instead set the ComputerName to something like WIN-0F47SUATAF5.
24
45
  # so this configuration will not really work... but its here to see when they fix this problem.
25
- Write-Host "Configuring sysprep to set ComputerName to $ComputerName..."
46
+ Write-Host 'Configuring sysprep...'
26
47
  Set-Content `
27
48
  -Encoding UTF8 `
28
49
  -Path $unattendPath `
29
50
  -Value (
30
51
  (Get-Content -Raw $unattendPath) `
31
- -replace '@@COMPUTERNAME@@',$ComputerName
52
+ -replace '@@COMPUTERNAME@@',$ComputerName `
53
+ -replace '@@USERNAME@@',$Username `
54
+ -replace '@@PASSWORD@@',$Password `
55
+ -replace '@@UNATTENDPS1PATH@@',$unattendPs1Path `
32
56
  )
57
+ Set-Content `
58
+ -Encoding UTF8 `
59
+ -Path $unattendPs1Path `
60
+ -Value @'
61
+ Set-StrictMode -Version Latest
62
+ $ErrorActionPreference = 'Stop'
63
+ $ProgressPreference = 'SilentlyContinue'
64
+ trap {
65
+ Write-Host "ERROR: $_"
66
+ Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
67
+ Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
68
+ Write-Host
69
+ Write-Host 'Sleeping during 60 minutes to give you time to see this error message...'
70
+ Start-Sleep -Seconds (60*60)
71
+ Exit 1
72
+ }
73
+
74
+ Write-Host @"
75
+ WARNING WARNING WARNING WARNING WARNING WARNING
76
+
77
+ this is being run by vagrant-windows-sysprep
78
+
79
+ do NOT touch anything
80
+
81
+ WARNING WARNING WARNING WARNING WARNING WARNING
82
+
83
+ "@
84
+
85
+ Write-Host 'Waiting for WinRM to be running...'
86
+ while ((Get-Service WinRM).Status -ne 'Running') {
87
+ Start-Sleep -Seconds 5
88
+ }
89
+
90
+ Write-Host 'Disabling auto logon...'
91
+ $autoLogonKeyPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
92
+ Set-ItemProperty `
93
+ -Path $autoLogonKeyPath `
94
+ -Name AutoAdminLogon `
95
+ -Value 0
96
+ Remove-ItemProperty `
97
+ -Path $autoLogonKeyPath `
98
+ -Name @(
99
+ 'DefaultDomainName',
100
+ 'DefaultUserName',
101
+ 'DefaultPassword'
102
+ ) `
103
+ -ErrorAction SilentlyContinue
104
+
105
+ Write-Host 'Logging off...'
106
+ logoff
107
+ '@
33
108
 
34
109
  Write-Host 'Syspreping...'
35
110
  C:/Windows/System32/Sysprep/sysprep.exe `
@@ -35,6 +35,20 @@
35
35
  <NetworkLocation>Home</NetworkLocation>
36
36
  <ProtectYourPC>1</ProtectYourPC>
37
37
  </OOBE>
38
+ <AutoLogon>
39
+ <Password>
40
+ <Value>@@PASSWORD@@</Value>
41
+ <PlainText>true</PlainText>
42
+ </Password>
43
+ <Enabled>true</Enabled>
44
+ <Username>@@USERNAME@@</Username>
45
+ </AutoLogon>
46
+ <FirstLogonCommands>
47
+ <SynchronousCommand wcm:action="add">
48
+ <Order>1</Order>
49
+ <CommandLine>PowerShell -File @@UNATTENDPS1PATH@@</CommandLine>
50
+ </SynchronousCommand>
51
+ </FirstLogonCommands>
38
52
  </component>
39
53
  </settings>
40
54
  </unattend>
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module WindowsSysprep
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-windows-sysprep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rui Lopes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake