How To Install The SharePoint PowerShell Snapin

IT Support Forum Forums Website Development DMS SharePoint Troubleshooting How To Install The SharePoint PowerShell Snapin

Tagged: ,

This topic contains 1 reply, has 1 voice, and was last updated by  Webmaster 5 years ago.

  • Author
  • #652


    Every time I want to user PowerShell to Do SharePoint commandlets, I have to install the snapin. How can I install the SharePoint PowerShell snapin automatically?

  • #653


    Apparently there are a number of ways to do this:

    • A shortcut to %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit add-pssnapin microsoft.sharepoint.powershell
    • Putting Add-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue at the start of any SharePoint PowerShell scripts
    • Creating a PowerShell profile using the commandlet:

      if (!(test-path $profile.AllUsersAllHosts)) {new-item -type file -path $profile.AllUsersAllHosts -force}
      powershell_ise $profile.AllUsersAllHosts

      Then adding the following code to the start of your script:

      $ver = $host | select version
      if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = “ReuseThread”}
      if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null) {
      Add-PSSnapin “Microsoft.SharePoint.PowerShell”

You must be logged in to reply to this topic.