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?