How To Install The SharePoint PowerShell Snapin

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

Tagged: ,

Viewing 1 reply thread
  • Author
    Posts
    • #652
      Webmaster
      Keymaster

      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
      Webmaster
      Keymaster

      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”
        }

Viewing 1 reply thread
  • You must be logged in to reply to this topic.