0

I've written a small function that displays WSUS updates ready for approval:

function get-WSUSInfo {
  $wsus = Get-WsusUpdate -Classification All -Approval AnyExceptDeclined -Status Needed

  foreach ($update in $wsus) {
    $props = @{
      'Title'=$update.Title;
      'Classification'=$update.Classification;
      'Approved'=$update.Approved;
    }

    $obj = New-Object -TypeName PSObject -Property $props

    Write-Output $obj
  }
}

However it doesn't populate the list with any of the update "Titles" for some reason. When I execute the command outside of the function, the output works exactly how I need it to, however when I execute the function itself it displays all other data with the exception of the "Title" for each update.

This displays all of the column data:

$wsus = Get-WsusUpdate -Classification All -Approval AnyExceptDeclined -Status Needed

but my function displays only the "Classification" & "Approved" column data.

Where am I going wrong?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Craig Smith
  • 37
  • 1
  • 7

1 Answers1

1

The Title is part of the Update itself, which is reference by the Update property:

$props = @{
    'Title'          = $update.Update.Title
    'Classification' = $update.Classification
    'Approved'       = $update.Approved
}
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206