| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 3 |
|
| 4 |
<settings pass="offlineServicing"/> |
| 5 |
<settings pass="windowsPE"> |
| 6 |
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> |
| 7 |
<SetupUILanguage> |
| 8 |
<UILanguage>en-US</UILanguage> |
| 9 |
</SetupUILanguage> |
| 10 |
<InputLocale>0409:00000409</InputLocale> |
| 11 |
<SystemLocale>en-US</SystemLocale> |
| 12 |
<UILanguage>en-US</UILanguage> |
| 13 |
<UserLocale>en-US</UserLocale> |
| 14 |
</component> |
| 15 |
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> |
| 16 |
<ImageInstall> |
| 17 |
<OSImage> |
| 18 |
<InstallTo> |
| 19 |
<DiskID>0</DiskID> |
| 20 |
<PartitionID>3</PartitionID> |
| 21 |
</InstallTo> |
| 22 |
</OSImage> |
| 23 |
</ImageInstall> |
| 24 |
<UserData> |
| 25 |
<ProductKey> |
| 26 |
<Key>2B87N-8KFHP-DKV6R-Y2C8J-PKCKT</Key> |
| 27 |
<WillShowUI>OnError</WillShowUI> |
| 28 |
</ProductKey> |
| 29 |
<AcceptEula>true</AcceptEula> |
| 30 |
</UserData> |
| 31 |
<UseConfigurationSet>false</UseConfigurationSet> |
| 32 |
<RunSynchronous> |
| 33 |
<RunSynchronousCommand wcm:action="add"> |
| 34 |
<Order>1</Order> |
| 35 |
<Path>cmd.exe /c ">>"X:\diskpart.txt" (echo SELECT DISK=0&echo CLEAN&echo CONVERT GPT&echo CREATE PARTITION EFI SIZE=300&echo FORMAT QUICK FS=FAT32 LABEL="System"&echo CREATE PARTITION MSR SIZE=16)"</Path> |
| 36 |
</RunSynchronousCommand> |
| 37 |
<RunSynchronousCommand wcm:action="add"> |
| 38 |
<Order>2</Order> |
| 39 |
<Path>cmd.exe /c ">>"X:\diskpart.txt" (echo CREATE PARTITION PRIMARY&echo SHRINK MINIMUM=1000&echo FORMAT QUICK FS=NTFS LABEL="Windows"&echo CREATE PARTITION PRIMARY&echo FORMAT QUICK FS=NTFS LABEL="Recovery")"</Path> |
| 40 |
</RunSynchronousCommand> |
| 41 |
<RunSynchronousCommand wcm:action="add"> |
| 42 |
<Order>3</Order> |
| 43 |
<Path>cmd.exe /c ">>"X:\diskpart.txt" (echo SET ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac"&echo GPT ATTRIBUTES=0x8000000000000001)"</Path> |
| 44 |
</RunSynchronousCommand> |
| 45 |
<RunSynchronousCommand wcm:action="add"> |
| 46 |
<Order>4</Order> |
| 47 |
<Path>cmd.exe /c "diskpart.exe /s "X:\diskpart.txt" >>"X:\diskpart.log" || ( type "X:\diskpart.log" & echo diskpart encountered an error. & pause & exit /b 1 )"</Path> |
| 48 |
</RunSynchronousCommand> |
| 49 |
<RunSynchronousCommand wcm:action="add"> |
| 50 |
<Order>5</Order> |
| 51 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo WScript.Echo "Scanning for newly created SYSTEM registry hive file to disable Windows Defender services..."&echo Set fso = CreateObject("Scripting.FileSystemObject"^))"</Path> |
| 52 |
</RunSynchronousCommand> |
| 53 |
<RunSynchronousCommand wcm:action="add"> |
| 54 |
<Order>6</Order> |
| 55 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo Set existing = CreateObject("Scripting.Dictionary"^)&echo Function Execute(command^)&echo WScript.Echo "Running command '" + command + "'"&echo Set shell = CreateObject("WScript.Shell"^))"</Path> |
| 56 |
</RunSynchronousCommand> |
| 57 |
<RunSynchronousCommand wcm:action="add"> |
| 58 |
<Order>7</Order> |
| 59 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo Set exec = shell.Exec(command^)&echo Do While exec.Status = 0&echo WScript.Sleep 100&echo Loop&echo WScript.Echo exec.StdOut.ReadAll&echo WScript.Echo exec.StdErr.ReadAll)"</Path> |
| 60 |
</RunSynchronousCommand> |
| 61 |
<RunSynchronousCommand wcm:action="add"> |
| 62 |
<Order>8</Order> |
| 63 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo Execute = exec.ExitCode&echo End Function&echo Function FindHiveFiles&echo Set FindHiveFiles = CreateObject("Scripting.Dictionary"^)&echo For Each drive In fso.Drives)"</Path> |
| 64 |
</RunSynchronousCommand> |
| 65 |
<RunSynchronousCommand wcm:action="add"> |
| 66 |
<Order>9</Order> |
| 67 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo If drive.IsReady And drive.DriveLetter ^<^> "X" Then&echo For Each folder In Array("$Windows.~BT\NewOS\Windows", "Windows"^))"</Path> |
| 68 |
</RunSynchronousCommand> |
| 69 |
<RunSynchronousCommand wcm:action="add"> |
| 70 |
<Order>10</Order> |
| 71 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo file = fso.BuildPath(fso.BuildPath(drive.RootFolder, folder^), "System32\config\SYSTEM"^)&echo If fso.FileExists(file^) And fso.FileExists(file + ".LOG1"^) And fso.FileExists(file + ".LOG2"^) Then)"</Path> |
| 72 |
</RunSynchronousCommand> |
| 73 |
<RunSynchronousCommand wcm:action="add"> |
| 74 |
<Order>11</Order> |
| 75 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo FindHiveFiles.Add file, Nothing&echo End If&echo Next&echo End If&echo Next&echo End Function&echo For Each file In FindHiveFiles)"</Path> |
| 76 |
</RunSynchronousCommand> |
| 77 |
<RunSynchronousCommand wcm:action="add"> |
| 78 |
<Order>12</Order> |
| 79 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo WScript.Echo "Will ignore file at '" + file + "' because it was already present when Windows Setup started."&echo existing.Add file, Nothing&echo Next&echo Do)"</Path> |
| 80 |
</RunSynchronousCommand> |
| 81 |
<RunSynchronousCommand wcm:action="add"> |
| 82 |
<Order>13</Order> |
| 83 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo For Each file In FindHiveFiles&echo If Not existing.Exists(file^) Then&echo ret = 1&echo While ret ^> 0&echo WScript.Sleep 500&echo ret = Execute("reg.exe LOAD HKLM\mount " + file^))"</Path> |
| 84 |
</RunSynchronousCommand> |
| 85 |
<RunSynchronousCommand wcm:action="add"> |
| 86 |
<Order>14</Order> |
| 87 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo Wend&echo For Each service In Array("Sense", "WdBoot", "WdFilter", "WdNisDrv", "WdNisSvc", "WinDefend"^))"</Path> |
| 88 |
</RunSynchronousCommand> |
| 89 |
<RunSynchronousCommand wcm:action="add"> |
| 90 |
<Order>15</Order> |
| 91 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo ret = Execute("reg.exe ADD HKLM\mount\ControlSet001\Services\" + service + " /v Start /t REG_DWORD /d 4 /f"^)&echo Next&echo ret = Execute("reg.exe UNLOAD HKLM\mount"^))"</Path> |
| 92 |
</RunSynchronousCommand> |
| 93 |
<RunSynchronousCommand wcm:action="add"> |
| 94 |
<Order>16</Order> |
| 95 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo WScript.Echo "Found and successfully modified SYSTEM registry hive file at '" + file + "'. This window will now close."&echo WScript.Sleep 5000&echo Exit Do&echo End If)"</Path> |
| 96 |
</RunSynchronousCommand> |
| 97 |
<RunSynchronousCommand wcm:action="add"> |
| 98 |
<Order>17</Order> |
| 99 |
<Path>cmd.exe /c ">>"X:\defender.vbs" (echo WScript.Sleep 1000&echo Next&echo Loop)"</Path> |
| 100 |
</RunSynchronousCommand> |
| 101 |
<RunSynchronousCommand wcm:action="add"> |
| 102 |
<Order>18</Order> |
| 103 |
<Path>cmd.exe /c "start /MIN cscript.exe //E:vbscript X:\defender.vbs"</Path> |
| 104 |
</RunSynchronousCommand> |
| 105 |
</RunSynchronous> |
| 106 |
</component> |
| 107 |
</settings> |
| 108 |
<settings pass="generalize"/> |
| 109 |
<settings pass="specialize"> |
| 110 |
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> |
| 111 |
<RunSynchronous> |
| 112 |
<RunSynchronousCommand wcm:action="add"> |
| 113 |
<Order>1</Order> |
| 114 |
<Path>powershell.exe -WindowStyle Normal -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;"</Path> |
| 115 |
</RunSynchronousCommand> |
| 116 |
<RunSynchronousCommand wcm:action="add"> |
| 117 |
<Order>2</Order> |
| 118 |
<Path>powershell.exe -WindowStyle Normal -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\Specialize.ps1' -Raw | Invoke-Expression;"</Path> |
| 119 |
</RunSynchronousCommand> |
| 120 |
<RunSynchronousCommand wcm:action="add"> |
| 121 |
<Order>3</Order> |
| 122 |
<Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> |
| 123 |
</RunSynchronousCommand> |
| 124 |
<RunSynchronousCommand wcm:action="add"> |
| 125 |
<Order>4</Order> |
| 126 |
<Path>powershell.exe -WindowStyle Normal -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\DefaultUser.ps1' -Raw | Invoke-Expression;"</Path> |
| 127 |
</RunSynchronousCommand> |
| 128 |
<RunSynchronousCommand wcm:action="add"> |
| 129 |
<Order>5</Order> |
| 130 |
<Path>reg.exe unload "HKU\DefaultUser"</Path> |
| 131 |
</RunSynchronousCommand> |
| 132 |
</RunSynchronous> |
| 133 |
</component> |
| 134 |
</settings> |
| 135 |
<settings pass="auditSystem"/> |
| 136 |
<settings pass="auditUser"/> |
| 137 |
<settings pass="oobeSystem"> |
| 138 |
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> |
| 139 |
<InputLocale>0409:00000409</InputLocale> |
| 140 |
<SystemLocale>en-US</SystemLocale> |
| 141 |
<UILanguage>en-US</UILanguage> |
| 142 |
<UserLocale>en-US</UserLocale> |
| 143 |
</component> |
| 144 |
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> |
| 145 |
<UserAccounts> |
| 146 |
<LocalAccounts> |
| 147 |
<LocalAccount wcm:action="add"> |
| 148 |
<Name>$USER</Name> |
| 149 |
<DisplayName/> |
| 150 |
<Group>Administrators</Group> |
| 151 |
<Password> |
| 152 |
<Value/> |
| 153 |
<PlainText>true</PlainText> |
| 154 |
</Password> |
| 155 |
</LocalAccount> |
| 156 |
</LocalAccounts> |
| 157 |
</UserAccounts> |
| 158 |
<AutoLogon> |
| 159 |
<Username>$USER</Username> |
| 160 |
<Enabled>true</Enabled> |
| 161 |
<LogonCount>1</LogonCount> |
| 162 |
<Password> |
| 163 |
<Value/> |
| 164 |
<PlainText>true</PlainText> |
| 165 |
</Password> |
| 166 |
</AutoLogon> |
| 167 |
<OOBE> |
| 168 |
<ProtectYourPC>3</ProtectYourPC> |
| 169 |
<HideEULAPage>true</HideEULAPage> |
| 170 |
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> |
| 171 |
<HideOnlineAccountScreens>false</HideOnlineAccountScreens> |
| 172 |
</OOBE> |
| 173 |
<FirstLogonCommands> |
| 174 |
<SynchronousCommand wcm:action="add"> |
| 175 |
<Order>1</Order> |
| 176 |
<CommandLine>powershell.exe -WindowStyle Normal -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\FirstLogon.ps1' -Raw | Invoke-Expression;"</CommandLine> |
| 177 |
</SynchronousCommand> |
| 178 |
</FirstLogonCommands> |
| 179 |
</component> |
| 180 |
</settings> |
| 181 |
<Extensions xmlns="https://schneegans.de/windows/unattend-generator/"> |
| 182 |
<ExtractScript> |
| 183 |
param( |
| 184 |
[xml] $Document |
| 185 |
); |
| 186 |
|
| 187 |
foreach( $file in $Document.unattend.Extensions.File ) { |
| 188 |
$path = [System.Environment]::ExpandEnvironmentVariables( $file.GetAttribute( 'path' ) ); |
| 189 |
mkdir -Path( $path | Split-Path -Parent ) -ErrorAction 'SilentlyContinue'; |
| 190 |
$encoding = switch( [System.IO.Path]::GetExtension( $path ) ) { |
| 191 |
{ $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; } |
| 192 |
{ $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); } |
| 193 |
default { [System.Text.Encoding]::Default; } |
| 194 |
}; |
| 195 |
$bytes = $encoding.GetPreamble() + $encoding.GetBytes( $file.InnerText.Trim() ); |
| 196 |
[System.IO.File]::WriteAllBytes( $path, $bytes ); |
| 197 |
} |
| 198 |
</ExtractScript> |
| 199 |
<File path="C:\Windows\Setup\Scripts\VirtIoGuestTools.ps1"> |
| 200 |
& { |
| 201 |
foreach( $letter in 'DEFGHIJKLMNOPQRSTUVWXYZ'.ToCharArray() ) { |
| 202 |
$exe = "${letter}:\virtio-win-guest-tools.exe"; |
| 203 |
if( Test-Path -LiteralPath $exe ) { |
| 204 |
Start-Process -FilePath $exe -ArgumentList '/passive', '/norestart' -Wait; |
| 205 |
return; |
| 206 |
} |
| 207 |
} |
| 208 |
'VirtIO Guest Tools image (virtio-win-*.iso) is not attached to this VM.'; |
| 209 |
} *>&1 >> 'C:\Windows\Setup\Scripts\VirtIoGuestTools.log'; |
| 210 |
</File> |
| 211 |
<File path="C:\Windows\Setup\Scripts\unattend-01.ps1"> |
| 212 |
bcdedit.exe -set TESTSIGNING ON; |
| 213 |
</File> |
| 214 |
<File path="C:\Windows\Setup\Scripts\unattend-02.ps1"> |
| 215 |
# https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration |
| 216 |
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0; |
| 217 |
Start-Service sshd; |
| 218 |
Set-Service -Name sshd -StartupType 'Automatic'; |
| 219 |
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force; |
| 220 |
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"; |
| 221 |
|
| 222 |
# Allow inbound connections |
| 223 |
Set-NetFirewallProfile -Profile Domain,Public,Private -DefaultInboundAction Allow; |
| 224 |
|
| 225 |
# Set up authorized keys |
| 226 |
echo "$AUTHORIZED_KEYS" | Out-File -Encoding utf8 -FilePath "C:\ProgramData\ssh\administrators_authorized_keys" |
| 227 |
</File> |
| 228 |
<File path="C:\Windows\Setup\Scripts\Specialize.ps1"> |
| 229 |
$scripts = @( |
| 230 |
{ |
| 231 |
net.exe accounts /lockoutthreshold:0; |
| 232 |
}; |
| 233 |
{ |
| 234 |
net.exe accounts /maxpwage:UNLIMITED; |
| 235 |
}; |
| 236 |
{ |
| 237 |
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" /v DisableNotifications /t REG_DWORD /d 1 /f; |
| 238 |
}; |
| 239 |
{ |
| 240 |
Set-ExecutionPolicy -Scope 'LocalMachine' -ExecutionPolicy 'RemoteSigned' -Force; |
| 241 |
}; |
| 242 |
{ |
| 243 |
reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d 1 /f; |
| 244 |
}; |
| 245 |
{ |
| 246 |
Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\VirtIoGuestTools.ps1' -Raw | Invoke-Expression; |
| 247 |
}; |
| 248 |
{ |
| 249 |
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\BitLocker" /v "PreventDeviceEncryption" /t REG_DWORD /d 1 /f; |
| 250 |
}; |
| 251 |
{ |
| 252 |
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v HideFirstRunExperience /t REG_DWORD /d 1 /f; |
| 253 |
}; |
| 254 |
{ |
| 255 |
Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\unattend-01.ps1' -Raw | Invoke-Expression; |
| 256 |
}; |
| 257 |
); |
| 258 |
|
| 259 |
& { |
| 260 |
[float] $complete = 0; |
| 261 |
[float] $increment = 100 / $scripts.Count; |
| 262 |
foreach( $script in $scripts ) { |
| 263 |
Write-Progress -Activity 'Running scripts to customize your Windows installation. Do not close this window.' -PercentComplete $complete; |
| 264 |
'*** Will now execute command «{0}».' -f $( |
| 265 |
$str = $script.ToString().Trim() -replace '\s+', ' '; |
| 266 |
$max = 100; |
| 267 |
if( $str.Length -le $max ) { |
| 268 |
$str; |
| 269 |
} else { |
| 270 |
$str.Substring( 0, $max - 1 ) + '…'; |
| 271 |
} |
| 272 |
); |
| 273 |
$start = [datetime]::Now; |
| 274 |
& $script; |
| 275 |
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds; |
| 276 |
"`r`n" * 3; |
| 277 |
$complete += $increment; |
| 278 |
} |
| 279 |
} *>&1 >> "C:\Windows\Setup\Scripts\Specialize.log"; |
| 280 |
</File> |
| 281 |
<File path="C:\Windows\Setup\Scripts\DefaultUser.ps1"> |
| 282 |
$scripts = @( |
| 283 |
{ |
| 284 |
$names = @( |
| 285 |
'ContentDeliveryAllowed'; |
| 286 |
'FeatureManagementEnabled'; |
| 287 |
'OEMPreInstalledAppsEnabled'; |
| 288 |
'PreInstalledAppsEnabled'; |
| 289 |
'PreInstalledAppsEverEnabled'; |
| 290 |
'SilentInstalledAppsEnabled'; |
| 291 |
'SoftLandingEnabled'; |
| 292 |
'SubscribedContentEnabled'; |
| 293 |
'SubscribedContent-310093Enabled'; |
| 294 |
'SubscribedContent-338387Enabled'; |
| 295 |
'SubscribedContent-338388Enabled'; |
| 296 |
'SubscribedContent-338389Enabled'; |
| 297 |
'SubscribedContent-338393Enabled'; |
| 298 |
'SubscribedContent-353698Enabled'; |
| 299 |
'SystemPaneSuggestionsEnabled'; |
| 300 |
); |
| 301 |
|
| 302 |
foreach( $name in $names ) { |
| 303 |
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v $name /t REG_DWORD /d 0 /f; |
| 304 |
} |
| 305 |
}; |
| 306 |
); |
| 307 |
|
| 308 |
& { |
| 309 |
[float] $complete = 0; |
| 310 |
[float] $increment = 100 / $scripts.Count; |
| 311 |
foreach( $script in $scripts ) { |
| 312 |
Write-Progress -Activity 'Running scripts to modify the default user’’s registry hive. Do not close this window.' -PercentComplete $complete; |
| 313 |
'*** Will now execute command «{0}».' -f $( |
| 314 |
$str = $script.ToString().Trim() -replace '\s+', ' '; |
| 315 |
$max = 100; |
| 316 |
if( $str.Length -le $max ) { |
| 317 |
$str; |
| 318 |
} else { |
| 319 |
$str.Substring( 0, $max - 1 ) + '…'; |
| 320 |
} |
| 321 |
); |
| 322 |
$start = [datetime]::Now; |
| 323 |
& $script; |
| 324 |
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds; |
| 325 |
"`r`n" * 3; |
| 326 |
$complete += $increment; |
| 327 |
} |
| 328 |
} *>&1 >> "C:\Windows\Setup\Scripts\DefaultUser.log"; |
| 329 |
</File> |
| 330 |
<File path="C:\Windows\Setup\Scripts\FirstLogon.ps1"> |
| 331 |
$scripts = @( |
| 332 |
{ |
| 333 |
Set-ItemProperty -LiteralPath 'Registry::HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'AutoLogonCount' -Type 'DWord' -Force -Value 0; |
| 334 |
}; |
| 335 |
{ |
| 336 |
Disable-ComputerRestore -Drive 'C:\'; |
| 337 |
}; |
| 338 |
{ |
| 339 |
Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\unattend-02.ps1' -Raw | Invoke-Expression; |
| 340 |
}; |
| 341 |
); |
| 342 |
|
| 343 |
& { |
| 344 |
[float] $complete = 0; |
| 345 |
[float] $increment = 100 / $scripts.Count; |
| 346 |
foreach( $script in $scripts ) { |
| 347 |
Write-Progress -Activity 'Running scripts to finalize your Windows installation. Do not close this window.' -PercentComplete $complete; |
| 348 |
'*** Will now execute command «{0}».' -f $( |
| 349 |
$str = $script.ToString().Trim() -replace '\s+', ' '; |
| 350 |
$max = 100; |
| 351 |
if( $str.Length -le $max ) { |
| 352 |
$str; |
| 353 |
} else { |
| 354 |
$str.Substring( 0, $max - 1 ) + '…'; |
| 355 |
} |
| 356 |
); |
| 357 |
$start = [datetime]::Now; |
| 358 |
& $script; |
| 359 |
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds; |
| 360 |
"`r`n" * 3; |
| 361 |
$complete += $increment; |
| 362 |
} |
| 363 |
} *>&1 >> "C:\Windows\Setup\Scripts\FirstLogon.log"; |
| 364 |
</File> |
| 365 |
</Extensions> |
| 366 |
</unattend> |