Skip to content

Instantly share code, notes, and snippets.

@cloaked-ninja
Created October 6, 2016 15:29
Show Gist options
  • Save cloaked-ninja/55cdc25f9c29e4771040b34702166d3a to your computer and use it in GitHub Desktop.
Save cloaked-ninja/55cdc25f9c29e4771040b34702166d3a to your computer and use it in GitHub Desktop.
Profile for SharePoint Powershell
#Test for existence using the Test-Path cmdlet
#Set up initial profile script for SharePoint in other programs
#Run this in any PowerShell window to create a new profile
if (!(Test-Path $profile.AllUsersAllHosts)) {
New-Item -Type File -Path $profile.ALlUsersAllHosts -Force}
powershell_ise $profile.AllUsersAllHosts
#this section taken from SharePoint.ps1 (SharePoint Manager program)
#important to set ThreadOptions for memory
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home
#End of SharePoint.ps1 section
#Add SharePoint PowerShell
$si = Get-PsSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
if ($si -eq $null) {
Add-PsSnapin "Microsoft.SharePoint.PowerShell"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment