In this article is going to be explained the differences between the Windows PowerShell console and the SharePoint Management Shell in SharePoint manage. SharePoint 2010 Management Shell loads a Windows PowerShell profile located in the SharePoint root. The profile’s path is: SharePointRoot CONFIG POWERSHELL Registration SharePoint.ps1.
This script configures the initial user environment for Windows PowerShell. The three things that the profile does are the followings:
Load the SharePoint snap-ins. Without the SharePoint snap-ins is impossible to interact with SharePoint.
In PowerShell you cannot perform any SharePoint task because that snap-ins is not loaded.
To load the SharePoint snap-ins, you must run the following command:
Another way to add functionality to Windows PowerShell is to use a process called reflection. For example: [System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=126.96.36.199, Culture=neutral, PublicKeyToken=71e9bce111e9429c”).
This was required in SharePoint 2007 but is not recommended in SharePoint 2010 where the SharePoint snap-in is available.
Set the PSThread option to Reuse Thread. This is a setting that improves the utilization of memory in Windows PowerShell and reduces the likelihood of memory leaks.
In Windows PowerShell, each command is started in its own execution thread. If you use Windows PowerShell you must run the following command:
$Host.Runspace.ThreadOptions = “ReuseThread”
This command set the ThreadOptions to “ReuseThread” making that each command run in the same thread.
Adds the Stsadm to the path
SharePoint Management Shell adds the path to the Stsadm.exe command to its path. Stasadm is located in SharePoint Root/ BIN folder. This allows you to use Stsadm to perform tasks, in addition to Windows PowerShell.
All the Stsadm operations are in the following link:
10174A Configuring and Administering Microsoft SharePoint 2010
Latest posts by SolidQ (see all)
- AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution by Using AlwaysOn Availability Groups - November 28, 2013
- Delete Web Parts in SharePoint 2010 and 2013 with Windows PowerShell - November 26, 2013
- Custom Master Pages not available from Performance Point Dashboard Designer - June 19, 2012