wintriallab/scripts/postinstall/autounattend-postinstall.ps1
Micah R Ledbetter 4192667eec wintriallab: WORKING BUILDS
- It can auto trigger WinRM enabling
- Use stronger password for vagrant user so WinRM will allow it
- Reboot after installing VBox Additions before running WSUS
- Way more verbose Packer
- Slightly better error handling in postinstall scripts
- Use the Event Log for logging in the postinstall module
- Fix lots of bugs that cropped up without me realizing
- Install VBox Additions from either ISO or attached disk
- Install from ISO by default (smoother in Packer)
- Accept EULA for Windows Updates where relevant
2015-10-30 19:47:57 -05:00

30 lines
1.1 KiB
PowerShell

[cmdletbinding()]
param()
import-module $PSScriptRoot\wintriallab-postinstall.psm1
try {
Write-EventLogWrapper "Starting the autounattend postinstall script"
Set-PasswordExpiry -accountName "vagrant" -expirePassword $false
Disable-HibernationFile
Enable-MicrosoftUpdate
Install-VBoxAdditions -fromDisc # Need to reboot for some of these drivers to take
# To reboot, then run Windows updates, then enable WinRM:
$restartCommand = "$PSHOME\powershell.exe -File A:\win-updates.ps1 -RestartAction RunAtLogon -PostUpdateExpression -CalledFromRegistry '$PSHOME\powershell.exe -File A:\enable-winrm.ps1'"
# 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
}
catch {
$message = "======== CAUGHT EXCEPTION ========`r`n$_`r`n"
$message += "======== ERROR STACK ========"
$error |% { $message += "$_`r`n----`r`n" }
$message += "======== ========"
Write-EventLogWrapper $message
exit 666
}