Cloud

Configure Windows PowerShell 3 ISE to automatically load SharePoint PowerShell Module

I wanted to start out by saying that PowerShell 3 and ISE are just awesome. The Microsoft team did a great job on all fronts, including simply getting this tool to load so much faster in comparsion to previous versions. Because of this I’ve started to use PowerShell 3 ISE for all of my SharePoint scripting needs. I’m not really a fan of either: 1) Always having to write the Add-PSSnapin or 2) Including my script libraries, when I simply want to do some quick scripting with PowerShell against SharePoint. As a result I wanted to be able to have this Add-PSSnapin run for me everytime I opened up PowerShell 3 ISE. This isn’t that difficult to do at all. In fact it only takes a little copy and paste effort 🙂

Step 1:Browse to the PowerShell system folder

Browse to C:\Windows\System32\WindowsPowerShell\v1.0
PowerShellFolder.tiff

Step 2: Edit the Profile file

Find the profile file and right click > Edit
EditProfileFile.tiff

​This should open up the file in PowerShell 3 ISE, if it is still set as the default for opening up .ps1 files

Step 3: Add the Add-PSSnapin code to the Profile file

Copy and paste the Add-PSSnapin code below
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
AddToProfileFile.tiff

 

Step 4: Close out of PowerShell 3 ISE

Close out of the ps1 file and PowerShell 3 ISE.
 

Step 5: Relaunch PowerShell 3 ISE

Open up PowerShell 3 ISE and attempt to use any of the SharePoint PowerShell actions you are accustom to. You should see them available. Another way to ensure that the auto loading is working for you is to verify that you see the Microsoft.SharePoint.PowerShell module listed under the Modules dropdown list found in the Command tab. Below is an image that shows that the SharePoint module has been loaded.
ISESPModuleAdded.tiff

Of course this isn’t rocket science or anything too great, but hey it allows me to simply open up PowerShell 3 ISE and be able to try something out right away without having some extra step that i always have to perform.
 

 

One Response

  1. Michelle Naraine September 11, 2013

Leave a Reply