PowerShell & SharePoint

Presented by Zach Rosenfield, Program Manager, Microsoft

He's starting with a basic (VERY basic) introduction to Powershell. <zone out>

</zone out>

Oooh, nice, you have tab-complete in PowerShell, I never noticed that J Guess I don't need to zone out quite yet!

If you use Start-Process it starts to prompt you for the parameters it needs.

CmdLet is a script block in the form of a verb-noun pair.

Now he's going over the history of SharePoint powershell.

SharePoint v1/v2

  • No command line interface

SharePoint 2007

  • STSADM: 182 commands

SharePoint 2010

  • 652 cmdlets
  • Superset of Admin UI
  • Extensible
  • In Line discoverability
  • Optimized for batch operations

Performance of operations compared to STSADM is much better.

12 hours compared to 30 minutes on enabling a feature on sites and subsites in a Farm

Two kinds of commands

  • Local – must be run on each box
  • Global – run only once on a farm

You must load the Powershell snap in for SharePoint

The rest of the presentation is all about demos, just going to type notes about highlights that catch me.

Nice, he's scripted his entire PowerShell demo in a Powershell script, no typos J

-whatif is an important parameter, this lets you check what your command is going to do without actually executing it.

[object]PipeBind – This is a unique identifier for an object. You can give anything that's unique to the object and it can find it if it's of that object type.

They've worked on adding a LOT of examples to the cmdlets, very nice indeed.

Correlation in errors will be very useful, you can search logs based on the ID and find out all relevant events that relate to that error.

One line commands that do not store objects to variables, it will auto-dispose the items.

Use Start-SPAssignment to start a monitor that watches what objects you are assigning to a variable. When you are finished with the variables/objects, the Stop-Assignment will dispose of all the items that were caught.

Must be careful because anything that is called, it will store them all in memory. You will get a warning if that does happen.

Another way is to create a local collector by not specifying –global.

Ooooh man, check out out-gridview, let's you create a dynamic graphical grid, it looks NICE.

Here's another nice one, he's demonstrating how you can create a site in a specific database. Ooh nice, there's also a cmdlet that allows you to move site collections between content databases. In the beta it warns you about IISReset, in RTM it won't need to be done. You can do this live, the site is set to read only during the move.

Nice, he's showing a script that will take an existing cmdlet, and puts a wrapper around it so you can extend an existing cmdlet with your own functionality.

When doing remote actions, you have to get the credentials that you can pass into scripts. NICE, it pops up a dialog box to get your credentials.

-AsJob lets you submit a remote script block, and let it run in the background so you can submit other commands. You access it by using Get-Job.

Oh man, another cool tool Out-gauge creates a live graphic object on the screen.

PowerGadgets is another cool tool he's using, he's generating graphs on the fly from the scripts.

Very good session, some great stuff for both SharePoint 2010, and I learned some new things about PowerShell.