forked from cloudbase/unattended-setup-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateAndSysprep.ps1
executable file
·31 lines (28 loc) · 1.19 KB
/
UpdateAndSysprep.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Param(
[switch]$InstallCloudbaseInit
)
$ErrorActionPreference = "Stop"
$Host.UI.RawUI.WindowTitle = "Installing updates..."
Get-WUInstall -AcceptAll -IgnoreReboot
if (Get-WURebootStatus -Silent)
{
$Host.UI.RawUI.WindowTitle = "Updates installation finished. Rebooting."
shutdown /r /t 0
}
else
{
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name Unattend*
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoLogonCount
if($InstallCloudbaseInit)
{
Invoke-WebRequest -Uri https://dl.dropboxusercontent.com/u/9060190/InstallCloudbaseInit.ps1 -OutFile C:\Windows\Temp\InstallCloudbaseInit.ps1
C:\Windows\Temp\InstallCloudbaseInit.ps1
#$Host.UI.RawUI.WindowTitle = "Running Sysprep..."
#C:\Windows\System32\Sysprep\Sysprep.exe /generalize /oobe /shutdown /unattend:"C:\Program\ Files\ (x86)\Cloudbase\ Solutions\Cloudbase-Init\conf\Unattend.xml"
}
else
{
$Host.UI.RawUI.WindowTitle = "Running Sysprep..."
C:\Windows\System32\Sysprep\Sysprep.exe /generalize /oobe /shutdown /unattend:C:\Windows\Temp\Unattend.xml
}
}