Living a SharePoint life

Wednesday, January 21, 2015

Code Snippet: Load the SharePoint PowerShell Module

How do you load the PowerShell module for SharePoint?

Addendum: I've added a try/catch block to the code. This way you can be sure the module is loaded.

# Loading SharePoint Module
try {
    if ((Get-PSSnapin "microsoft.SharePoint.Powershell" -ea silentlycontinue) -eq $null)
        Add-PSSNapin Microsoft.SharePoint.Powershell
catch {
    throw "Microsoft SharePoint PowerShell AddIn initialization failed"
    exit 3

Featured Post

How are Microsoft Search quota consumed?

With Office 365 Search, Microsoft has created a central entry point for the modern workplace. In one convenient spot, users can access all ...