PortValhalla/scripts/Windows/OS/Upgrade.ps1

21 lines
561 B
PowerShell
Raw Normal View History

2023-06-21 20:04:18 +00:00
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;
}
}