I'm using the cmdlet Get-SPWeb in my script but not working so I used Add-PSSnapin Microsoft.Sharepoint.Powershell to resolve the problem. Eventhough I still get an error when I use Add-PSSnapin Microsoft.Sharepoint.Powershell command here is the error msg :

  • Add-PSSnapin Microsoft.Sharepoint.Powershell
  •   + CategoryInfo          : InvalidArgument : (Microsoft.Sharepoint.Powershe 
    ll:String) [Add-PSSnapin], PSArgumentException
      + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad 

I'm using powershell ISE version 5 and PnP script.

Please help ! Thanks in advance.

1 Answer 1


Before you can do anything with PowerShell ISE, you need to make sure that

(1) You are running SharePoint Management Shell or PowerShell ISE as an Administrator


(2) that the execution policy is set in such a way that you can execute scripts.

Please follow the steps:

1.Open SharePoint Management Shell and run as an admin:


enter image description here

2.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

3.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"

enter image description here

4.When that has loaded, try another command, such as


enter image description here

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

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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