Andrew Connell

As mentioned in my interview on the SharePoint PodShow - my PowerShell utility setup script

In the last interview I did with the Rob Foster on the SharePoint PodShow (#17), I mentioned a PowerShell script I use to prep my PowerShell command environment with stuff I need. Got a few hits on Twitter requesting this so here ya go.Namely, it loads common SharePoint assemblies and sets an alias to STSADM. I got the idea from an old post on Karine Bosch's blog (note, she has a new blog here).Copy the contents of this file into a new text file and save it to a common place on your machine. I call mine LoadSPAssemblies.ps1 and put it into a SharePoint utility folder I have in Mesh (sync'd to all my dev machines... both physical and virtual):set-executionpolicy unrestricted [System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")new-alias "stsadm" ($env:CommonProgramFiles + "\Microsoft Shared\web server extensions\12\BIN\stsadm.exe") Then, when I need to use it I just type the path to the PS1 file and it loads the assemblies and sets an alias to STSADM. Of course, your assemblies may differ... I just do a lot of work with the Publishing namespace. :)[Updated 3/12/2009] Updated to no longer use the LoadWithPartialName and instead use the Load method. Thanks to the commenter below.Technorati Tags:...

In the last interview I did with the Rob Foster on the SharePoint PodShow (#17) , I mentioned a PowerShell script I use to prep my PowerShell command environment with stuff I need. Got a few hits on Twitter requesting this so here ya go.

Namely, it loads common SharePoint assemblies and sets an alias to STSADM. I got the idea from an old post on Karine Bosch’s blog (note, she has a new blog here ).

Copy the contents of this file into a new text file and save it to a common place on your machine. I call mine LoadSPAssemblies.ps1 and put it into a SharePoint utility folder I have in Mesh (sync’d to all my dev machines… both physical and virtual):

set-executionpolicy unrestricted

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

new-alias “stsadm” ($env:CommonProgramFiles + “\Microsoft Shared\web server extensions\12\BIN\stsadm.exe”)

Then, when I need to use it I just type the path to the PS1 file and it loads the assemblies and sets an alias to STSADM. Of course, your assemblies may differ… I just do a lot of work with the Publishing namespace. :)

[Updated 3/12/2009] Updated to no longer use the LoadWithPartialName and instead use the Load method. Thanks to the commenter below.

Andrew Connell
Founder & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to delivering industry-leading on-demand video training to professional developers. He lives with his wife & two kids in Florida.