Tuesday, April 1, 2014

Adding SharePoint 2013 PowerShell Module SnapIn in the ISE

The PowerShell Integrated Scripting Environment (ISE) is awesome, but the SharePoint module is not loaded by default.

Can you make it smarter? Of course!

To make it smarter in the just once term just type the following code in the ISE on your sever (if the ISE isn't loaded on your server just add it as a Feature from Server Manager)

Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell

But you'll have to do that every time you open the ISE. To make the ISE permanently smarter on that system you can create a profile that loads this automatically
(Does this take anyone else back to autoexec.bat?)

1. Open Powershell ISE and run this script to create a new profile:
if (!(test-path $profile.AllUsersAllHosts))
{new-item -type file -path $profile.AllUsersAllHosts-force}

2. Then run the following script to edit the profile:
 psedit $profile.allusersallhosts
3. Finally, configure the profile to support SharePoint: 
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

Save profile.ps1 and close PowerShell ISE
Reopen ISE and verify success with the following command:
Get-Command Get-SP*

No comments: