2023-06-16 18:10:34 +00:00
|
|
|
Import-Module PSWindowsUpdate;
|
|
|
|
Import-Module ScheduledTasks;
|
|
|
|
|
2023-06-16 18:24:22 +00:00
|
|
|
$installerPath = "$PSScriptRoot/Install.ps1";
|
2023-06-16 18:10:34 +00:00
|
|
|
$setupPath = "$($MyInvocation.MyCommand.Path)";
|
|
|
|
|
|
|
|
Install-WindowsUpdate -AcceptAll -IgnoreReboot;
|
|
|
|
|
|
|
|
if ((Get-WindowsUpdate).Count -gt 0)
|
|
|
|
{
|
|
|
|
$nextScript = "$setupPath";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$nextScript = "$installerPath";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Get-WURebootStatus).RebootRequired)
|
|
|
|
{
|
|
|
|
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$nextScript`"" -PropertyType ExpandString;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
. "$nextScript";
|
|
|
|
}
|