Streamline SharePoint administration with PowerShell script

I've developed a PowerShell script that loads common SharePoint assemblies and sets an alias to STSADM for easy command execution. Check it out.

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. :)

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

Andrew Connell is a web & cloud 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 helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment