Centralize script for rebooting
This commit is contained in:
parent
4668ffc42a
commit
2365d3320c
2 changed files with 7 additions and 1 deletions
|
@ -12,7 +12,7 @@ function Invoke-Upgrade([Context] $context)
|
|||
Write-Information "A Reboot is Required!";
|
||||
Write-Information "Windows will reboot now and the installation will be continued automatically.";
|
||||
$null = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$($context.EntryPoint)`"" -PropertyType ExpandString;
|
||||
Restart-Computer;
|
||||
$context.Reboot();
|
||||
exit;
|
||||
}
|
||||
elseif ((Get-WindowsUpdate -IgnoreReboot).Count -gt 0)
|
||||
|
|
|
@ -61,4 +61,10 @@ class Context {
|
|||
$null = New-Item -ItemType Directory $tempDir;
|
||||
return $tempDir;
|
||||
}
|
||||
|
||||
[void] Reboot() {
|
||||
Write-Host "Restarting Computer...";
|
||||
$null = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$($this.EntryPoint)`"" -PropertyType ExpandString;
|
||||
Restart-Computer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue