harbar.net component based software & platform hygiene

Adding SharePoint 2010 PoweShell cmdlets to your PowerShell ISE

Print | posted on Monday, May 03, 2010 11:55 PM

PowerShell for SharePoint 2010 rocks. No, really it does. You hate it at first, but then it’s all pure goodness. But boy, does the UI SUCK! Crap for productivity, crap for demos, just about crap for anything other than lame jokes about old skool shell scripting.

Sure, there are funky PowerShell GUIs out there, but they appear to cost money. The good news is Windows ships with it’s own IDE. This thing is called an ISE – prey how much do marketing people get paid?

Anyway – that’s what I’ve been using for all my demos to show the PowerShell stuff that I do. Better than a command prompt. Trouble is this bad boy doesn’t load the SharePoint cmdlets, so you have to do that before working with SharePoint.

The good news is you can add the guff necessary to load the DLL in a PowerShell ISE profile. It’s a very basic thing, but you may find it useful. To set it up, use the following PowerShell. This one is a user profile, you can change this to be a machine wide one if you wish (refer to this article).

# creates a local user powershell ISE profile
if (!(test-path $profile )) 
{new-item -type file -path $profile -force} 

# opens it for edit
psEdit $profile

# copy the following into the new file and save it
cd 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration'
.\SharePoint.ps1
cd \

# now everytime you run powershell ise as the same user - it will load the SP cmdlets automatically on start up

Happy ISEing!