locked
Wsus Powershell AND Superceded updates RRS feed

  • Question

  • I'll have this 'updateScope' filtering to retrieve the list of updates from a single computer.

    And I'm using 'LatestRevisionApproved', but when I run it I'm also getting  some superceded Updates, that I'm not interested on it, because I know that computer will never apply.

    I may add an additional filter by each update, but Is this setting the good one to filter SuperCeded Updates? Why is not working as I expect?

    $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.UpdateSources = [Microsoft.UpdateServices.Administration.UpdateSources]::MicrosoftUpdate;
    $updatescope.ExcludedInstallationStates=@('NotApplicable','Installed')
    $updatescope.ToCreationDate = (get-date).AddDays(-$days)
    
    
    $wsus.GetComputerTargetbyName($computername) 
    
     $updatelist = $mycomputer.GetUpdateInstallationInfoPerUpdate($updateScope)  | where {$_.GetUpdate().IsSuperseded -eq $False}
      write-output "Number of Pending updates $($updatelist.count)"
     "Search Range From: {0:dd-MMM-yyyy} To: {1:dd-MMM-yyyy} (-{2} Days)" -f $updatescope.FromCreationDate,$updatescope.ToCreationDate,$Days
     
      foreach ($update in $updatelist ) {
            $updateinfo=$update.Getupdate()
     
              [pscustomobject][Ordered]@{
                Status=$update.UpdateInstallationState
                Approval=$update.UpdateApprovalAction
                ArrivalDate=get-date $updateinfo.ArrivalDate -format dd-MMM-yyyy
              #  ApprovalTargetGroup=$update.GetUpdateApprovalTargetGroup().name
                PublicationState=$Updateinfo.PublicationState   # expired?
                Approved=$updateinfo.isapproved
                KB=$updateinfo | %{$_.KnowledgebaseArticles -join ","}
                SuperSeded=$updateinfo.IsSuperseded
                Declined=$updateinfo.IsDeclined
                Title=$updateinfo.title
              }
       
          }

    Regards

    Friday, January 18, 2019 10:59 AM

All replies

  • Hello,

    As I mentioned before, you need to add a scope property "ApprovedComputerTargetGroups", here is its description.



    Try to add it in your script and then check if superseded updates appear again.
     
    Hope my answer could help you and look forward to your feedback.
     
    Best Regards,
    Ray 


    Please remembers to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, January 21, 2019 6:49 AM
  • Hello,
     
    I noticed that you have not updated for several days. Has your issue been solved or is there any update?
     
    Feel free to feedback.
     
    Best Regards,
    Ray

    Please remembers to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, January 25, 2019 11:34 AM