if (!(test-path $profile.AllUsersAllHosts)) {new-item -type file -path $profile.AllUsersAllHosts -force}
powershell_ise $profile.AllUsersAllHosts
#Add the following code to the script file and save your changes:
$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"
}
This particular script will load the SharePoint snap-ins, but you can switch those last two lines for whatever snap-ins you wish. For instance:
((Get-PSSnapin "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin"
}
This would add the Exchange snapin instead of the SharePoint.
Micosoft has a snap-in for just about every solution they produce, and 3rd parties are beginning to put out snap-ins as well. The easiest way to find yours would be to simply google "Add-PSSnapin Name"
Thanks for posting this Kris!
ReplyDeleteNo problem! If there is anything in particular you are looking for just let me know...
ReplyDeleteLooks like this is way above my paygrade :)
ReplyDeleteNo doubt, powershell is way too much power for a Cop to be handling!
Delete