Okay all you PowerShell superstars out there that have been using my STSADM commands – I need your help! I’ve decided to teach myself PowerShell and see if I can’t leverage some of my STSADM experiences/code to expose some SharePoint functionality and I need some people who really know this PowerShell stuff to please take a look at what I’ve got so far and let me know if I’m way off base or not.

My initial stab includes 11 new cmdlets (10 Get and 1 Add):

  • Get-SPContentType-gl
  • Get-SPContentTypeUsages-gl
  • Get-SPFarm-gl
  • Get-SPField-gl
  • Add-SPList-gl
  • Get-SPList-gl
  • Get-SPSite-gl
  • Get-SPUserProfileManager-gl
  • Get-SPPrivacyPolicyManager-gl
  • Get-SPWeb-gl
  • Get-SPWebApplication-gl

The first thing you’ll hopefully notice is that I’ve adopted a naming convention similar to what I did with my STSADM commands – I looked everywhere for best practices on naming custom cmdlets to avoid name clashes but couldn’t find a darn thing (documentation for creating cmdlets is absolutely horrible!). What does everyone think of this approach? I tried to at least keep the verb-product+noun nomenclature so that you’d still be able to easily see all the get commands without having to also search -gl (so rather than gl-get-spfarm which would break a search for get-*).

I don’t currently have help completed for all the commands, only a couple of them as I wanted to wait until I got some feedback before investing too much time in this. I guess I should first ask if people see the need for this? Am I wasting my time? I want to learn PowerShell either way so I’ll create stuff regardless but I’d like to be able to share with the community for some mutual benefits.

So, if you know PowerShell and have time to play with what I’ve created thus far (take a look at the code too and see if I’m doing anything stupid) please feel free to download the source and installer:

  • Setup Package: Lapointe.SharePoint.PowerShell.Commands.Setup.msi
    • I’m currently NOT including my custom STSADM extensions in the install package so you’ll need to download and install those separately as they are a required dependency (see the links at the top of the page) – I may change this later so that the installer installs the STSADM extensions but I just don’t want to have to worry about that at the moment (for now I’m just pushing out builds for both products at the same time).
  • Source Code: SPPoSH.zip
    • Crack it open, be honest, be brutal, but please, be constructive 🙂

Keep in mind that this is just an initial “Alpha” release to see what people think – if you’ve followed my blog any or used my STSADM extensions then you can probably guess that there’ll be a lot more of these cmdlets in the future so I want to make sure that I’m taking the right approach. Also – if you have any ideas for cmdlets that would be really helpful please let me know and I’ll see if I can put something together as part of my learning exercise.

Thanks again to anyone who is able to help me out with this!

Update 12/14/2008: Based on feedback received (thanks Harley!) I’ve made one significant modification – the Get-SPSite-gl and Get-SPWeb-gl cmdlets now return back wrapper objects: SPSiteInfo and SPWebInfo, respectively. These wrapper objects allow the caller to not have to worry about calling Dispose() which is particularly useful when the results have been filtered. The Info objects contain virtually all the properties that their equivalent SP classes contain. You can still get to the actual object by calling the SPBase property or the GetSPObject().