Reply To: How To Install The SharePoint PowerShell Snapin

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

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