getting various failure responses
without the check = 1 - 4, I get
:n/a
:NaN
for my output; with that code section, I get that sections response when running through SAM.
Run locally in PS, this works...
the "test" script from help works through SAM...
something to do with New-Object I thing...
$ErrorActionPreference = "silentlycontinue";
$Error.Clear();
$res = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$lvl = $res.notificationlevel
if (-not($lvl -eq 1 -or $lvl -eq 2 -or $lvl -eq 3 -or $lvl -eq 4))
{
Write-Host "Message.WinUpdates: lvl is not eq 1-4: $res";
Write-Host "Statistic.WinUpdates: $lvl"
exit 1;
}
switch ($lvl)
{
1 {$msg="Windows Updates set to `"Never Check`""}
2 {$msg="Windows Updates set to `"Check but let me choose to download/install`""}
3 {$msg="Windows Updates set to `"Download but let me choose to install`""}
4 {$msg="Windows Updates Updates set to `"Auto Update`""}
}
# Write-Host $msg
if ($Error.Count -eq 0) {
Write-Host "Message.WinUpdates: $msg"
Write-Host "Statistic.WinUpdates: $lvl"
Exit 0;
}
Write-Host "Message: $($Error[0])";
Exit 1;