2015-09-24 23:33:39 +00:00
|
|
|
[cmdletbinding()]
|
|
|
|
param()
|
|
|
|
|
|
|
|
import-module $PSScriptRoot\wintriallab-postinstall.psm1
|
|
|
|
|
|
|
|
try {
|
2015-10-31 00:47:57 +00:00
|
|
|
Write-EventLogWrapper "Starting the autounattend postinstall script"
|
2015-09-24 23:33:39 +00:00
|
|
|
Set-PasswordExpiry -accountName "vagrant" -expirePassword $false
|
|
|
|
Disable-HibernationFile
|
|
|
|
Enable-MicrosoftUpdate
|
2015-10-31 00:47:57 +00:00
|
|
|
Install-VBoxAdditions -fromDisc # Need to reboot for some of these drivers to take
|
|
|
|
|
|
|
|
# To reboot, then run Windows updates, then enable WinRM:
|
2015-11-02 17:33:54 +00:00
|
|
|
$restartCommand = "$PSHOME\powershell.exe -File A:\win-updates.ps1 -CalledFromRegistry -RestartAction RunAtLogon -PostUpdateExpression '$PSHOME\powershell.exe -File A:\enable-winrm.ps1'"
|
2015-10-31 00:47:57 +00:00
|
|
|
|
|
|
|
# To reboot, then run winrm immediately without Windows Update
|
|
|
|
#$restartCommand = "$PSHOME\powershell.exe -File A:\enable-winrm.ps1"
|
|
|
|
|
|
|
|
Set-RestartRegistryEntry -restartAction RunAtLogon -restartCommand $restartCommand
|
|
|
|
Restart-Computer -force
|
2015-10-28 21:31:21 +00:00
|
|
|
}
|
2015-09-24 23:33:39 +00:00
|
|
|
catch {
|
2015-10-31 00:47:57 +00:00
|
|
|
$message = "======== CAUGHT EXCEPTION ========`r`n$_`r`n"
|
|
|
|
$message += "======== ERROR STACK ========"
|
|
|
|
$error |% { $message += "$_`r`n----`r`n" }
|
|
|
|
$message += "======== ========"
|
|
|
|
Write-EventLogWrapper $message
|
2015-09-24 23:33:39 +00:00
|
|
|
exit 666
|
|
|
|
}
|