How Do I Run PowerShell?
On every Windows Server running a variation
of Windows Server 2008 or higher, PowerShell is installed and can be
used for administration purposes. By default, the PowerShell
application appears in the Windows taskbar. Right-clicking the
application button displays available menu options, as shown in Figure 1.
Figure 1. The PowerShell application button provides a menu of options.
Selecting Import System Modules launches
PowerShell and loads all modules from all services and server
applications running on the current server. This is useful when
scripting code for more than one set of services (such as SharePoint
and SQL Server).
Selecting the Windows PowerShell ISE launches
a pseudo-development environment in which you can create, execute,
test, and debug PowerShell scripts. It is a glorified text editor but
is helpful in creating and running scripts.
Note
Although PowerShell is automatically
installed using Windows Server 2008 R2 and above, the ISE may or may
not be activated depending on other server product installations. If it
appears that the PowerShell ISE is not installed on the server, you
must activate it as a server feature.
Selecting the Windows PowerShell
menu item launches PowerShell in plain vanilla form (no additional
modules or support for server applications—including SharePoint—are
loaded). If you are not logged on as an administrator, select the Run
As Administrator menu item to launch PowerShell with administrative
privileges.
How Do I Make PowerShell Aware of SharePoint?
Launching PowerShell on the server opens a
blue console application window. Without importing any modules, this
instance does not know how to execute any SharePoint commands. To make
this PowerShell instance aware of SharePoint, you must add the
SharePoint PowerShell snap-in using the following command (as shown in Figure 2):
Add-PsSnapIn Microsoft.SharePoint.PowerShell
Figure 2. Adding the SharePoint PowerShell snap-in.
What Is the SharePoint 2013 Management Shell?
The SharePoint 2013 Management Shell is a
variation of PowerShell geared toward the administration and management
of SharePoint. After SharePoint is installed on the server, the
management console is available from the Start menu, as shown in Figure 3.
Figure 3. SharePoint 2013 Management Shell on the Start menu.
Selecting the SharePoint 2013 Management Shell launches the management console, as shown in Figure 4.
Figure 4. SharePoint 2013 Management Shell console window.
The management console window knows
about SharePoint commands, as well as general PowerShell commands.
What Is the SharePoint 2013 Management Shell Loading?
If you dig a little deeper and look at the
properties of the SharePoint 2013 Management Shell menu item, you will
notice that the SharePoint 2013 Management Shell involves nothing more
than running PowerShell with a SharePoint script, as shown Figure 5.
Figure 5. SharePoint 2013 Management Shell properties.
The SharePoint script that the menu item is loading is located within the SharePoint 15 hive, under the PowerShell Registration
folder, as shown in Figure 6.
Figure 6. SharePoint 2013 PowerShell Registration folder contents.
Tip
Crack open some of the files located in the Registration folder to gain some insights on the SharePoint commands and operations.