20 lines
561 B
PowerShell
20 lines
561 B
PowerShell
function Invoke-Upgrade([Context] $context)
|
|
{
|
|
$null = Import-Module PSWindowsUpdate;
|
|
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot;
|
|
|
|
if ((Get-WURebootStatus).RebootRequired)
|
|
{
|
|
$null = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$($context.EntryPoint)`"" -PropertyType ExpandString;
|
|
exit;
|
|
}
|
|
elseif ((Get-WindowsUpdate).Count -gt 0)
|
|
{
|
|
$null = Invoke-Upgrade $context;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|