Creating collection objects in PowerShell
Just a quick post on some PowerShell today – I have been doing some work around deplying WSP files through PowerShell (doing it programatically, not through STSADM) and I did come up against one thing that got me a bit stumped. When you use the “New-Object” cmdlet you need to get it to create a collection object (in my case I basically needed Collection but done in PowerShell).
It is doable, but the catch is that when you specify the object that the collection is made up of you need to use the fully qualified name of the class, including its assembly. So for me to create the SPWebApplication collection I used:
New-Object "System.Collections.ObjectModel.Collection``1[[Microsoft.SharePoint.Administration.SPWebApplication, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]"
So you can use that to create collections and other generic lists, enjoy!




No trackbacks yet.