Mar 1, 2009

BASTA! Spring 09: SharePoint & PowerShell

Many peoples asked me to share my presentation about SharePoint & PowerShell from the BASTA! Spring 09 – here it is.

In general .NET developers aren’t familiar with PowerShell, though it’s really great and helpful tool. I recommend everyone just use it! If you master it, every piece of software is your slave, regardless it is based on .NET, COM or WMI.

The base evolution of PowerShell is everything in PowerShell is a .NET object!

In the Java magazine they compared the Bash with PowerShell and PowerShell won, because it is build on .NET.

There are many SharePoint-Solution-Life-Cycle-Tasks and for sure .NET tasks PowerShell can help you:

  • Migration
  • Build Process
  • Deployment
  • Prototyping
  • Automate Admin Tasks
  • Rapid Development
  • Learning
  • Alternative UI
  • Trouble Shooting
  • Admin-Tool for your own Software
  • Testing
  • Scripting language for your own software

My favorite is scripting language for your own software. It is really cool and powerful to build PowerShell functions around your .NET DLLs. By the way, same does Microsoft.

What do you think how SharePoint 14 can be scripted? Stsadm.exe?

 One of my fun demos to demonstrate the power of PowerShell:

  • Automate PowerPoint, create slide on the fly and post a tweet


$pptApp = new-object -com "powerpoint.application"

$ppt = $pptApp.Presentations.Add()

$slide = $ppt.Slides.Add(1,1)

$shape = $slide.Shapes.Item(1)

$shape.TextFrame.TextRange.Text ="PowerShell rocks!"



## Now replace "PowerShell rocks!" with the following script:

## "Twitter this via PowerPoint" | out-twitter

## out-twitter is slightly modified version of Jeff Hicks Out-Twitter

## paste the out-twitter script to your $profile


## you have to add "$request.ServicePoint.Expect100Continue = $false"

## Now invoke your script from PowerShell with the following line:

Invoke-Expression $shape.TextFrame.TextRange.Text

Made the complete presentation this way ;-)

I’ve also a done a demo how you can embed PowerShell in a SharePoint WebPart in about 5 minutes. Following soon…

Some pics of the presenation:

 b2 b1

You will see what the chain saw meant when you watch the presentation ;-)