23 lines
719 B
PowerShell
23 lines
719 B
PowerShell
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
|
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
|
Install-Module pswindowsupdate
|
|
Import-Module pswindowsupdate
|
|
|
|
$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state
|
|
|
|
try {
|
|
if (((Get-WindowsUpdate -Title "Windows 11, version 23H2").status -eq "-D-----") -and ($scheduledTaskState.value -ne "Ready")) {
|
|
Write-Host "Update Downloaded but not scheduled"
|
|
Exit 1
|
|
}
|
|
elseif ($scheduledTaskState.value -eq "Ready") {
|
|
Write-Host "Update Downloaded and Scheduled"
|
|
Exit 0
|
|
}
|
|
Write-Host "Not Compliant"
|
|
Exit 1
|
|
}
|
|
catch {
|
|
Write-Host "Not Compliant - Catch"
|
|
Exit 1
|
|
} |