Load SharePoint Snapin to PowerShell ISE by Default

Problem:  If you use the PowerShell ISE to edit your SharePoint-PowerShell scripts, you may notice that SharePoint cmdlets are not available by default until you explicitly load them with the “Add-PSSnapin” cmdlet. This is because the ISE doesn’t load SharePoint PowerShell Snap-ins by default.

Solution: Here is the nifty trick to load SharePoint snap-in in PowerShell ISE by default! All you have to do is: Add the SharePoint snap-in to your PowerShell ISE profile file on your SharePoint server, which is getting executed each time you fire PowerShell ISE! Here is how:

To make sure that the PowerShell ISE profile file is created, run the following:

#Check if the profile file exists already  
if (test-path $profile)
    write-host "profile file already exists at: $profile"
    #Create the profile file
    New-Item -type file -path $profile -force
    write-host "profile file has been created!"

More on creating and managing PowerShell profile file is here: How to Create the PowerShell Profile?. This script will create a new profile file if it isn’t created already! Your output will be something like this:

add sharepoint snapin to powershell ise

Open the profile file you received from the above script and add the below line. (in my case, its: C:\Users\salaudeen\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1), save and close.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

So, from now on, you don’t need to explicitly load SharePoint PowerShell snapins as your first line of script! This will definitely save your time and enhance your scripting experience. To make this change for all users, use: $profile.AllUsersAllHosts instead of $profile in the above script.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

2 thoughts on “Load SharePoint Snapin to PowerShell ISE by Default

  • Hi,
    I am still unable to add the SharePoint snapin successfully.
    Would you be able to help further?
    I continue to get the same error stating the cmdlet is not recognized or the snapin is not registered
    Name : Microsoft.PowerShell.Core
    PSVersion : 5.0.10586.117

    • The PowerShell Snapin for SharePoint On-premises is available only on the servers of the Farm! So, Make sure you are running it on any of your SharePoint server.


Leave a Reply

Your email address will not be published. Required fields are marked *