2015-11-02 23:27:46 +00:00
|
|
|
[cmdletbinding()] param()
|
2015-09-24 23:33:39 +00:00
|
|
|
|
|
|
|
import-module $PSScriptRoot\wintriallab-postinstall.psm1
|
2015-11-11 21:50:37 +00:00
|
|
|
$errorActionPreference = "Stop"
|
2015-09-24 23:33:39 +00:00
|
|
|
|
2015-11-02 23:27:46 +00:00
|
|
|
Invoke-ScriptblockAndCatch -scriptBlock {
|
2015-10-31 00:47:57 +00:00
|
|
|
Write-EventLogWrapper "Starting the autounattend postinstall script"
|
2015-11-02 23:27:46 +00:00
|
|
|
Set-IdleDisplayPoweroffTime -seconds 0
|
2015-09-24 23:33:39 +00:00
|
|
|
Set-PasswordExpiry -accountName "vagrant" -expirePassword $false
|
|
|
|
Disable-HibernationFile
|
|
|
|
Enable-MicrosoftUpdate
|
2015-11-02 23:27:46 +00:00
|
|
|
Set-AllNetworksToPrivate # Required for Windows 10, not required for 81, not sure about other OSes
|
2015-10-31 00:47:57 +00:00
|
|
|
Install-VBoxAdditions -fromDisc # Need to reboot for some of these drivers to take
|
|
|
|
|
2015-11-11 21:50:37 +00:00
|
|
|
Set-PinnedApplication -Action PinToTaskbar -Filepath "$PSHOME\Powershell.exe"
|
|
|
|
Set-PinnedApplication -Action PinToTaskbar -Filepath "${env:SystemRoot}\system32\eventvwr.msc"
|
|
|
|
|
2015-10-31 00:47:57 +00:00
|
|
|
# To reboot, then run Windows updates, then enable WinRM:
|
2015-11-02 23:27:46 +00:00
|
|
|
$winRmCommand = "$PSHome\powershell.exe -File A:\enable-winrm.ps1"
|
2015-11-11 21:50:37 +00:00
|
|
|
$winUpdateCommand = "$PSHOME\powershell.exe -File A:\win-updates.ps1 -RestartAction RunAtLogon -PostUpdateExpression `"$winRmCommand`""
|
|
|
|
|
2015-11-02 23:27:46 +00:00
|
|
|
# To install Windows Updates then enable WinRM after reboot:
|
2015-11-11 21:50:37 +00:00
|
|
|
Set-RestartRegistryEntry -restartAction RunAtLogon -restartCommand $winUpdateCommand
|
2015-11-02 23:27:46 +00:00
|
|
|
|
|
|
|
# To just enable WinRM without installing updates after reboot:
|
|
|
|
#Set-RestartRegistryEntry -restartAction RunAtLogon -restartCommand $winRmCommand
|
|
|
|
|
2015-11-11 21:50:37 +00:00
|
|
|
$message = "Checking restart registry key: `r`n"
|
|
|
|
Get-RestartRegistryEntry | select -expand StringRepr |% { $message += "`r`n$_`r`n"}
|
|
|
|
Write-EventLogWrapper $message
|
|
|
|
|
2015-10-31 00:47:57 +00:00
|
|
|
Restart-Computer -force
|
2015-11-11 21:50:37 +00:00
|
|
|
}
|