Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm attempting to use the PowerShell ISE on a Win 2012 Standard Server.

I followed the steps here (http://sharepointpromag.com/blog/powershell-and-sharepoint-step-1-loading-dlls-and-snap-ins) to add the SharePoint Snapin which worked on my DEV box but in my TEST environment I'm having some strange behavior.

This lists all of the assemblies without any issue.

[AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object { Split-Path $_.Location -Leaf } | Sort

I load Microsoft.SharePoint.PowerShell with this assembly and verify it with the command above. However, I have to explicitly load each DLL. If I use "Microsoft.SharePoint" as the value it does not load the PowerShell assembly.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.PowerShell")

This does not display any values, SharePoint or otherwise which if found the strangest part.

Get-PSSnapin

This fails which makes sense, since there are not Snapins listed about.

Add-PSSnapin Microsoft.SharePoint.PowerShell

On another note, I'm able to execute the SharePoint Powershell console without an issue.

Question:
How can I add the SharePoint Snapin in the PowerShell ISE?
How can I debug why no PSSnapins appear to be registered?

share|improve this question
    
What version of SharePoint and what version of PowerShell is in use? –  Trevor Seward Jan 1 at 1:06
add comment

1 Answer

up vote 3 down vote accepted

Before you can do anything with PowerShell ISE, you need to make sure that (1) You are running PowerShell ISE as an Administrator and (2) that the execution policy is set in such a way that you can execute scripts.

Open SharePoint Management Shell and run

Get-ExecutionPolicy

If you get RemoteSigned, Unrestricted or Bypass you can safely continue. RemoteSigned means that you can't run scripts that are downloaded from the another server or the internet unless it is signed. If you download files to run in PowerShell ISE, set the execution policy to unrestricted, like this:

Set-ExecutionPolicy Unrestricted

If all works as expected, run PowerShell ISE as an Administrator. Then try to load the SharePoint.PowerShell with the following:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

When that has loaded, try another command, such as

Get-SPManagedAccount

If you receive no error messages, then you have SharePoint.PowerShell loaded. If not, run

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

and read the error messages. Copy the first line of the error received and try to search for it. Still in trouble? Update your answer with the error message, and I'll try to help if you notify me in a comment.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.