I have been writing the following script to retrieve information from WSUS 3.2 and am getting returned information with the last command under PowerShell 4.0
However when this script is run under PowerShell 2.0 no information is returned
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$approveState = 'Microsoft.UpdateServices.Administration.ApprovedStates' -as [type]
$installableitem = 'Microsoft.UpdateServices.Administration.FileForInstallableItem' -as [type]
$ApprovedFiles = @()
$Removable=0
$NotRemovable=0
$updateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope -Property @{
ApprovedStates = $approveState::LatestRevisionApproved#,NotApproved,Declined,HasStaleUpdateApprovals,LatestRevisionApproved
}
$Approved = $wsus.GetUpdates($updateScope)
Write-Host Approved Update $Approved.count
If ($Approved.count -GT 0) {
$Counter = 0
$Approved | ForEach-Object {
$ApprovedFiles += $_.Getinstallableitems().files.fileuri.segments
}
}
this is important as I am tiring to run this script on SBS 2011 server which can only run PowerShell 2.0.
Any assistance with this or an equivalent command appreciated
Thanks