Hello,
I've already done a basic script to get a report of approved updates by queried computer, but in some cases the results are reporting some 'NotApproved' updates
$computername='testcomputer.mydomain.com'
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope
$updateScope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::LatestRevisionApproved # Includes updates whose latest revision is approved.
$updateScope.UpdateApprovalActions = [Microsoft.UpdateServices.Administration.UpdateApprovalActions]::Install
$updatescope.ExcludedInstallationStates=@('NotApplicable','Installed')
$mycomputer=$wsus.GetComputerTargetbyName($computername)
foreach ($update in $mycomputer.GetUpdateInstallationInfoPerUpdate($updateScope) ) {
$updateinfo=$update.getupdate()
[pscustomobject][Ordered]@{
Status=$update.UpdateInstallationState
Approval=$update.UpdateApprovalAction
ArrivalDate=get-date $updateinfo.ArrivalDate -format dd-MMM-yyyy
Title=$updateinfo.title
}
}
This code produces a short report of pending updates on the majority of my computers, but In some I got results like these
Status Approval ArrivalDate Title
------ -------- ----------- -----
NotInstalled NotApproved 08-Aug-2017 Update for Windows Server 2012 R2 (KB4033428)
NotInstalled NotApproved 10-Jan-2018 Microsoft .NET Framework 4.7 for Windows 8.1 and Windows Server 2012 R2 for x64 (KB3186539)
NotInstalled NotApproved 11-Jul-2018 Microsoft .NET Framework 4.7.1 for Windows 8.1 and Windows Server 2012 R2 for x64 (KB4033369)
NotInstalled NotApproved 24-Jul-2018 Update for Windows Server 2012 R2 (KB4339284)
NotInstalled NotApproved 10-Oct-2018 2018-10 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4462941)
NotInstalled NotApproved 18-Oct-2018 Update for Windows Server 2012 R2 (KB4462901)
What is the reason that some computers are reporting 'NotApproved' action? Is the following filter the appropriate by my purposes -> [Microsoft.UpdateServices.Administration.UpdateApprovalActions]::Install
Or should I add a second filtering like -> $mycomputer.GetUpdateInstallationInfoPerUpdate($updateScope) | where {$_.UpdateApprovalAction -ne 'NotApproved'}
Best Regards