View Single Post
Old 11-25-2007   #1 (permalink)
Bob Landau


 
 

Has anyone used Powershell to script WSUS?

I've written a script which will fetch a category and classification on the
WSUS server; for instance 'Windows XP' and 'Critical Updates', 'Security
Updates', 'Service Packs', 'Update Rollups' respectively.

Most of it went smoothly however I had to jump through some hoops that I am
at a lose to see why it was necessary.

WSUS will return instances of these collections

[Microsoft.UpdateServices.Administration.UpdateClassificationCollection]

and

[Microsoft.UpdateServices.Administration.UpdateCategoryCollection]


These collections have the following hierarchy

[Microsoft.UpdateServices.Administration.UpdateCategoryCollection] is
derived from [Microsoft.UpdateServices.Administration.WsusCollection] who's
base class is[System.Collections.CollectionBase]


The trouble is when either of these are returned in by a function the object
type which gets returned is a System.Object[]. Powershell doesn't have any
problem instanciating either of these types but it will change this into a
object[]

The second problem is if either of these are used within a Pipeline assigment

$updates = $updates2 | where {$_.IsSuperseded -eq $false}

Powershell again change the type within the expression to object[] and
returns the error that it can't convert System.Object[] to
[Microsoft.UpdateServices.Administration.UpdateCategoryCollection]

As an aside I've read hear I believe that Powershell can't work with
generics does anyone know whether this is true?

To the best of my knowledge these are generics


thx
bob
My System SpecsSystem Spec