Friday, November 5, 2010

How to Become a SharePoint PowerShell Ninja in 4 Easy Steps

If you’re at all interested in PowerShell, here’s 4 easy steps to becoming a powershell ninja:

  1. Learn .NET.  PowerShell is .NET in the commandline.  The more .NET you know, the more you’ll know PowerShell.  If you’re stuck trying to figure out how some PowerShell thing works, run $mything.GetType() and look it up in MSDN.  In SharePoint for example, $mything = Get-SPWeb http://somesite; $mything.GetType() returns a SPWeb instance, which you can learn all about on MSDN.
  2. Use the ‘intellisense’ in PowerShell.  You can use <tab> to step through members on a variable, like this: $mything. <tab>  OR you can use get-member, like this : $mything | Get-Member
  3. Use ‘gcm *Something*’ alot.  Do you want to know commands related to SharePoint Search? gcm *Search*.  The naming is usually consistent, so you can do things like “gcm Get-SP*”, if you know you want to get some SP thing.
  4. Use get-help <command> alot.  Read up the help.  Sometimes it’s more helpful than others, but usually –examples will at least put you on the right track and teach you about pipes, where, and foreach.

That’s it.  Lather, Rinse, Repeat, and before long, you’ll be slinging scripts instead of poking around in tedious CA or Site Settings pages.

No comments: