Add a script for installing windows updates
This commit is contained in:
parent
b5ff2571e7
commit
6138ad7ffa
1 changed files with 33 additions and 0 deletions
33
scripts/Windows/OS/Setup.ps1
Normal file
33
scripts/Windows/OS/Setup.ps1
Normal file
|
@ -0,0 +1,33 @@
|
|||
foreach ($module in @("PSWindowsUpdate"))
|
||||
{
|
||||
if (-not (Get-Module $module))
|
||||
{
|
||||
Install-Module -AcceptLicense -Force "$module";
|
||||
}
|
||||
}
|
||||
|
||||
Import-Module PSWindowsUpdate;
|
||||
Import-Module ScheduledTasks;
|
||||
|
||||
$installerPath = "$PSScriptRoot/Manage.ps1";
|
||||
$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";
|
||||
}
|
Loading…
Reference in a new issue