Tuesday, June 21, 2016

Add sharepoint snap in to all powershell windows

The post below explains a very convenient way to add SharePoint snap in to powershell windows on dev server.

In brief:

  1. Run following command in Powershell ISE
    • if (!(test-path $profile.AllUsersAllHosts)) {new-item -type file -path $profile.AllUsersAllHosts –force} powershell_ise $profile.AllUsersAllHosts
  2. Append following code to the newly open powershell file
    • $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" }
Also, you might like the environment path to include some of the key locations e.g.

$env:Path = $env:Path + "C:\Program Files
\Common Files\Microsoft Shared\Web Server Extensions\15\Bin;C:\Windows\System32\inetsrv\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64"


https://blogs.msdn.microsoft.com/kaevans/2011/11/14/add-microsoft-sharepoint-powershell-snap-in-to-all-powershell-windows/

No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...