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.
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):
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=188.8.131.52, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Publishing, Version=184.108.40.206, 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.comments powered by Disqus