vagrant-windows-sysprep 0.0.6 → 0.0.7

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: 1dc2d54aaf1260b1b665c8afc61aec19116513971ef3a582d66dadbf8b87bac1
4
- data.tar.gz: 17831c91386bbac85c1cde8d97161931fe811a76ee5b014630784488c819ffab
3
+ metadata.gz: 7485e27038ee16b5957ffb8e3f86b80111a40956193c2f0dfeaed7e26abef79a
4
+ data.tar.gz: 3b0df055d9fd21204d0c50a81ce25de86b2ca400074767e38f43a4a57a5023ea
5
5
  SHA512:
6
- metadata.gz: 7a34bf9e4cecfaf135997d18072b163cd14b670469bf23ca01d953c9fa8ded715c2ff098efec0825b6664db43d681cb4e20667b538c8643caa76ab1b1b94abe6
7
- data.tar.gz: f40b0fde31aaff64913839a1367dab5a081373c09a40d8fd4eda712d1f189598c86cbbc95d7721af528de200612855eb1aea30f0a4432694437c18f013dcdee1
6
+ metadata.gz: 4c6a5e221e82270e2e6ba516dac9b3ae4923e555814c45399a108189bd1dd6046cb9fc824ebf07d1f80577d9efd7ec02b5006e0dcefa469d7a4b993f9e2c8c96
7
+ data.tar.gz: bc11b1b4cf19a9eebd6e6f2f68d40627eaa5f7b3fcb63799c25343d2ad684078b9e87e59f7920fcc5b0a91cbd1ea2ef9ea003eb6c6acf6913effe037ffb8c6d6
@@ -21,6 +21,15 @@ if (!$ComputerName) {
21
21
  $unattendPath = "$PSScriptRoot\vagrant-windows-sysprep-unattend.xml"
22
22
  $unattendPs1Path = "$PSScriptRoot\vagrant-windows-sysprep-unattend.ps1"
23
23
 
24
+ # sysprep renames the user that has the well-known Administrator SID
25
+ # to the Administrator name, when $Username has that SID, we must
26
+ # rename Administrator back to the $Username name.
27
+ # NB this SID always has the format S-1-5-21-<domain>-500.
28
+ # see https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems
29
+ $administratorLocalUser = Get-LocalUser | Where-Object {$_.SID.Value -match '^S-1-5-21-.+-500$'}
30
+ $enableAdministrator = $administratorLocalUser.Enabled
31
+ $renameAdministratorToUsername = $administratorLocalUser.Name -eq $Username
32
+
24
33
  # NB doing an auto-logon after a sysprep has two effects:
25
34
  # 1. make Windows 10 1809 not ask for an account creation (regardless of the
26
35
  # value of SkipUserOOBE/SkipMachineOOBE).
@@ -52,12 +61,9 @@ Set-Content `
52
61
  -replace '@@COMPUTERNAME@@',$ComputerName `
53
62
  -replace '@@USERNAME@@',$Username `
54
63
  -replace '@@PASSWORD@@',$Password `
55
- -replace '@@UNATTENDPS1PATH@@',$unattendPs1Path `
64
+ -replace '@@UNATTENDPS1PATH@@',$unattendPs1Path
56
65
  )
57
- Set-Content `
58
- -Encoding UTF8 `
59
- -Path $unattendPs1Path `
60
- -Value @'
66
+ $unattendPs1 = @'
61
67
  Set-StrictMode -Version Latest
62
68
  $ErrorActionPreference = 'Stop'
63
69
  $ProgressPreference = 'SilentlyContinue'
@@ -82,6 +88,16 @@ WARNING WARNING WARNING WARNING WARNING WARNING
82
88
 
83
89
  "@
84
90
 
91
+ if ($enableAdministrator) {
92
+ Get-LocalUser -Name Administrator | Enable-LocalUser
93
+ } else {
94
+ Get-LocalUser -Name Administrator | Disable-LocalUser
95
+ }
96
+
97
+ if ($renameAdministratorToUsername) {
98
+ Get-LocalUser -Name Administrator | Rename-LocalUser -NewName $Username
99
+ }
100
+
85
101
  Write-Host 'Waiting for WinRM to be running...'
86
102
  while ((Get-Service WinRM).Status -ne 'Running') {
87
103
  Start-Sleep -Seconds 5
@@ -104,7 +120,14 @@ Remove-ItemProperty `
104
120
 
105
121
  Write-Host 'Logging off...'
106
122
  logoff
107
- '@
123
+ '@ `
124
+ -replace '\$enableAdministrator',"$(if ($enableAdministrator) {'$true'} else {'$false'})" `
125
+ -replace '\$renameAdministratorToUsername',"$(if ($renameAdministratorToUsername) {'$true'} else {'$false'})" `
126
+ -replace '\$Username',"'$Username'"
127
+ Set-Content `
128
+ -Encoding UTF8 `
129
+ -Path $unattendPs1Path `
130
+ -Value $unattendPs1
108
131
 
109
132
  Write-Host 'Syspreping...'
110
133
  C:/Windows/System32/Sysprep/sysprep.exe `
@@ -41,8 +41,14 @@
41
41
  <PlainText>true</PlainText>
42
42
  </Password>
43
43
  <Enabled>true</Enabled>
44
- <Username>@@USERNAME@@</Username>
44
+ <Username>Administrator</Username>
45
45
  </AutoLogon>
46
+ <UserAccounts>
47
+ <AdministratorPassword>
48
+ <Value>@@PASSWORD@@</Value>
49
+ <PlainText>true</PlainText>
50
+ </AdministratorPassword>
51
+ </UserAccounts>
46
52
  <FirstLogonCommands>
47
53
  <SynchronousCommand wcm:action="add">
48
54
  <Order>1</Order>
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module WindowsSysprep
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -4,8 +4,8 @@ rescue LoadError
4
4
  raise "The Vagrant Windows Sysprep plugin must be run within Vagrant."
5
5
  end
6
6
 
7
- if Vagrant::VERSION < "2.1.2"
8
- raise "The Vagrant Windows Sysprep plugin is only compatible with Vagrant 2.1.2+"
7
+ if Vagrant::VERSION < "2.2.7"
8
+ raise "The Vagrant Windows Sysprep plugin is only compatible with Vagrant 2.2.7+"
9
9
  end
10
10
 
11
11
  module VagrantPlugins
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.6
4
+ version: 0.0.7
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-09-16 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake