none
Using the Get-WsusUpdate cmdlet in PowerShell, ComputersNeedingThisUpdate always shows zero

    Question

  • I've written a PowerShell script for email notification of WSUS updates awaiting approval.  The problem I'm having is that the ComputersNeedingThisUpdate property always shows zero, even when there are computers which need the update.  The other Computers counts match the WSUS MMC Snap-In, just the ComputersNeedingThisUpdate is wrong.  Any ideas out there?  Is this a bug in the WSUS PowerShell Module?

    I'm running WSUS on Windows Server 2012.  The script is as follows:

    $UpdNeeded = Get-WsusUpdate -Approval Unapproved -Status FailedOrNeeded $txt_body = "Updates with Errors or Awaiting Approval`n`n" ForEach ($Upd in $UpdNeeded) { $txt_body += $Upd.Update.Title+"`n" $txt_body += $Upd.Update.Description+"`n" $txt_body += "Computers Needing Update: "+$Upd.ComputersNeedingThisUpdate+"`n" $txt_body += "Computers With Errors: "+$Upd.ComputersWithErrors+"`n" }

    If ($UpdNeeded.Count -gt 0) {
    # Send Email
    }



    Thursday, September 12, 2013 10:20 PM

All replies

  • Hi,

    Thanks for the question.

    Please try the following instead

    PS C:\> Get-WsusUpdate -Classification All -Approval Unapproved -Status FailedOrNeeded

    If issue persists, you can try to post the question in our PowerShell forum for further assistance.

    Hope this helps.


    Best Regards
    Jeremy Wu

    Saturday, September 14, 2013 5:17 PM
    Moderator
  • Hi,

    I would like to check if you need further assistance.

    Thanks.


    Best Regards
    Jeremy Wu

    Wednesday, September 18, 2013 10:29 AM
    Moderator
  • Thanks for the reply Jeremy.

    I still haven't figured this out.  I've run the following:

    PS C:\> Get-WsusUpdate -Classification All -Status FailedOrNeeded

    I know there are updates that are needed, based on the WSUS management console, but the above command doesn't return anything.  Any other ideas?

    Wednesday, September 18, 2013 9:12 PM
  • Thanks for the reply Jeremy.

    I still haven't figured this out.  I've run the following:

    PS C:\> Get-WsusUpdate -Classification All -Status FailedOrNeeded

    I know there are updates that are needed, based on the WSUS management console, but the above command doesn't return anything.  Any other ideas?

    Did you try the command that Jeremy_Wu recommended?

    PS C:\> Get-WsusUpdate -Classification All -Approval Unapproved -Status FailedOrNeeded

    Wednesday, September 18, 2013 9:18 PM
    Moderator
  • I've modified my script as follows:

    $UpdNeeded = Get-WsusUpdate -Classification All -Approval Unapproved -Status FailedOrNeeded

    $html_body = "<h1>Updates Awaiting Approval</h1>`n<p><bold>Count: "+$UpdNeeded.Count+"</bold></p>"
    $txt_body = "Updates Awaiting Approval`n Count: "+$UpdNeeded.Count+"`n`n"
    ForEach ($Upd in $UpdNeeded) {
        $html_body += "<p><b>"+$Upd.Update.Title+"</b><br/><small>"+$Upd.Update.Description
    #    $html_body += "<br/>Computers Needing Update: "+$Upd.ComputersNeedingThisUpdate
    #    $html_body += "<br/>Computers With Errors: "+$Upd.ComputersWithErrors
        $html_body += "</small></p>`n"

        $txt_body +=  $Upd.Update.Title+"`n"
        $txt_body +=  $Upd.Update.Description+"`n"
        $txt_body +=  "Computers Needing Update: "+$Upd.ComputersNeedingThisUpdate+"`n"
        $txt_body += "Computers With Errors: "+$Upd.ComputersWithErrors+"`n"
        $txt_body +=  "`n"
    }
    I've forced a condition in the WSUS console where there are unapproved updates that are needed.  However, the ComputersNeedingThisUpdate property is zero for all of these updates?  How can that be?  I know they are needed because a) Get-WsusUpdate is returning them, b) I've confirmed in the WSUS console.  The count should be >=1.



    Wednesday, September 18, 2013 9:34 PM