Monday 19 August 2019

Windows Powershell With SharePoint Server 2013 - Part I



Using Windows PowerShell to administer a SharePoint Server 2013 environment. You’ll move onto exploring how you can use PowerShell scripting to administer your SharePoint Server 2013 farm, learn how to assign and create variables, and use the SharePoint object model from Windows PowerShell, and learn Windows PowerShell scripting techniques that simplify administration tasks in SharePoint Server 2013.

After completing series of this articles, you will be better able to: Find your way around the SharePoint 2013 Management Shell and interact with SharePoint Web applications, site collections, and sites. Use Windows PowerShell scripting techniques, such as pipes, filters, wildcards, and enumerations, for SharePoint Server 2013 administration. Explain how to create and assign variables and use the SharePoint object model from Windows PowerShell.

Technologies : Windows PowerShell, SharePoint Server 2013

Scenario: This article takes you through an introduction to using the Windows PowerShell in SharePoint Server 2013 Search user experience with emphasis on exploring the cmdlet interface, new features, configuration options, and customization of SharePoint Servers.

Getting Started and Setting up your SharePoint 2013 Management Shell Environment 

Connect to the Environment

Launch the SharePoint 2013 Management Shell. Click Start, then click Microsoft SharePoint 2013 Products, and then click SharePoint 2013 Management Shell. The SharePoint 2013 Management Shell command line window will open.


At the PS > prompt, type the following command and press ENTER:

Get-Command –pssnapin "Microsoft.SharePoint.PowerShell" |more

This command displays all the available cmdlets in the Microsoft.SharePoint.PowerShell 2013 namespace. Press SPACE to page down the list. As you can see, there are hundreds of cmdlets relating to a wide range of administrative tasks.

          Note: You can also type gcm as shorthand for Get-Command.



To get help and information on a particular cmdlet, you can use the Get-Help <cmdlet-name>  command. 

Type the following command, and then press ENTER: 

get-help Get-SPSite 

The console window displays information on how to use the Get-SPSite cmdlet. 

As you might have guessed, cmdlets that include the Get prefix return information. You can use these cmdlets to write information to the console, or to provide information to other cmdlets.

You can also use the Get-Help <cmdlet-name>-detailed OR Get-Help <cmdlet-name>-full command options to retrieve more detailed technical information on a specific cmdlet.

As some of these help files can be very long, remember that you can append < | more, and then click to any command if you want to page the command output.

Type the following command, and then press ENTER:

Get-SPSite –WebApplication http://intranet.contoso.com 

This command returns all the site collections that exist in the http://intranet.contoso.com Web application.


You can use the same approach to retrieve information at each level of the SharePoint architecture. For example, you can retrieve all the Web applications in your server farm, all the site collections within a specific Web application, or all the individual sites within a site collection. We will explore this concept in the next task.

Retrieving Information from the Server Farm 

The SharePoint snap-in for Windows PowerShell includes many straightforward cmdlets that can retrieve information from your SharePoint Server farm without requiring the ability to write sophisticated scripts. In addition to being invaluable tools for day-to-day administration tasks, the cmdlets are a starting point to learn Windows PowerShell. Some of these tasks include retrieving information from various sources so you can perform daily management tasks, such as a SharePoint server farm.

In this task, you will explore cmdlets that retrieve information from a SharePoint server farm.

When you’re not sure which cmdlet you need to perform a particular task, you can use the Get-Command cmdlet to find out what is available. Let's say you want to review which cmdlets can retrieve information from SharePoint Server 2013.

Type the following command, and press ENTER:

Get-Command Get-SP* |more 

The console window displays the names of all the cmdlets that start with Get-SP. The verb Get is common to all cmdlets that return information, and the noun prefix SP is common to all SharePoint cmdlets. The asterisk ( * ) is a wildcard character that returns any of a defined subset of all possible characters.


         Note: You can use the same approach to find cmdlets relating to specific areas of functionality.                      For example, <Get-Command * Service*> will return all service-related cmdlets.

Commonly Used Get Cmdlets 

Two of the commonly used Get cmdlets are Get-SPServiceApplication Identity and Get-SPServiceApplication – Select ID, Name.

Type the following command, and then press ENTER:

Get-SPServiceApplication | Select ID, Name 

The console window displays the ID and Name properties of each service application that is running in the server farm.

Let's say a review of the event logs identifies a problem with a Service Application, and provides a GUID of: < 66c958d1-d10a-4880-bfc3-8b2646b8e4cd >. You need to find out which of the current service applications is causing the problem to be able to fix it. Use the Get-SPServiceApplication – Identity cmdlet to find it.

Type the following command, and then press ENTER:

Get-SPServiceApplication –Identity 66c958d1-d10a-4880-bfc3-8b2646b8e4cd 

The console window provides details of the service application and identifies the corresponding IIS application pool with DisplayName, TypeName, and the ID of the service application





                                                                                                              ==>> KUMAR NUGALAPU
                                                                                                                         Senior Consultant



No comments:

Post a Comment