2015-11-14 00:43:43 +00:00
|
|
|
[cmdletbinding(DefaultParameterSetName="RunWindowsUpdates")] param(
|
|
|
|
[Parameter(ParameterSetName="RunWindowsUpdates")] [switch] $RunWindowsUpdates,
|
|
|
|
[Parameter(Mandatory=$true,ParameterSetName="SkipWindowsUpdates")] [switch] $SkipWindowsUpdates
|
|
|
|
)
|
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-11-16 23:48:32 +00:00
|
|
|
Set-PasswordExpiry -accountName "vagrant" -disable
|
2015-09-24 23:33:39 +00:00
|
|
|
Disable-HibernationFile
|
|
|
|
Enable-MicrosoftUpdate
|
2015-10-31 00:47:57 +00:00
|
|
|
|
2015-11-14 00:43:43 +00:00
|
|
|
# Need to reboot for some of these drivers to take
|
|
|
|
# Requires that the packer file attach the Guest VM driver disc, rather than upload it
|
|
|
|
# (Uploading it also gives problems when using WinRM - too big? - so this is a better solution anyway)
|
|
|
|
Install-VBoxAdditions -fromDisc
|
2015-11-11 21:50:37 +00:00
|
|
|
|
2015-11-14 00:43:43 +00:00
|
|
|
# Required for Windows 10, not required for 81, not sure about other OSes
|
|
|
|
# Should probably happen after installing Guest VM drivers, in case installing the drivers would cause Windows to see the network as a new connection
|
|
|
|
Set-AllNetworksToPrivate
|
2015-11-11 21:50:37 +00:00
|
|
|
|
2015-11-14 00:43:43 +00:00
|
|
|
switch ($PsCmdlet.ParameterSetName) {
|
|
|
|
"RunWindowsUpdates" { $restartCommand = [ScriptBlock]::Create("A:\win-updates.ps1 -PostUpdateExpression A:\enable-winrm.ps1") }
|
|
|
|
"SkipWindowsUpdates" { $restartCommand = [ScriptBlock]::Create("A:\enable-winrm.ps1") }
|
|
|
|
default { throw "Not configured for this parameter set..." }
|
|
|
|
}
|
|
|
|
Set-RestartScheduledTask -RestartCommand $restartCommand | out-null
|
2015-10-31 00:47:57 +00:00
|
|
|
Restart-Computer -force
|
2015-11-11 21:50:37 +00:00
|
|
|
}
|
2015-11-14 00:43:43 +00:00
|
|
|
|