Monday 19 August 2019


SharePoint Feature Management in PowerShell - Part 2


In this task, you will learn how to use the PowerShell commands to find GUID and other information about features in the SharePoint server.

In the course of many routine deployment and troubleshooting tasks, you will need to find the GUID that corresponds to a particular SharePoint feature. In previous versions of SharePoint products and technologies, this tended to be a long, complicated task. As a result, administrators would find themselves coming up with complicated strategies or resort to performing full-text searches of the Features folder on the file system. SharePoint Server 2013 provides a far more straightforward approach to this problem through Windows PowerShell.

To get a list of all the installed features in a SharePoint server farm, type the following command, and then press ENTER:

Get-SPFeature |more 

The console window provides a list of all the installed features in the server farm, together with an ID and scope for each feature.

       Note: The full returned list of –SPFeatures can be very long. Use the < |more> syntax to shorten the list until you press the SPACE button.



In addition to retrieving a list all the installed features in a server farm, you may want to retrieve a list of all the features that are activated to a particular scope.

To do this, you can add switch parameters to the Get-SPFeature cmdlet (Site, Web, WebApplication, or Farm).

Type the following command, and then press ENTER:

Get-SPFeature –Site http://intranet.contoso.com |more 

The console window shows a list of all activated features on the intranet.contoso.com site collection.



One particularly useful application of PowerShell for SharePoint Server 2013 administrators is PowerShell's built-in ability to parse SharePoint log files.

To parse a SharePoint log file, type the following command, and then press ENTER:

Get-SPLogEvent | Select –Last 10 

The console window displays the last ten messages that were written to the log files.

       Note: This command may take several seconds to complete.



The Select cmdlet can be used to limit the number of items returned from other cmdlets that return large numbers of results. As you work through the remaining exercises in this lab, you will see how to use this technique and others to create sophisticated filtering techniques to return specific information.

Create Site Settings and Properties 

In this task, you will explore how you can put these cmdlets to use in your SharePoint server farm to create sites and manage site setting properties using the Set-SPSite cmdlet.

In addition to retrieving information, the SharePoint snap-in for Windows PowerShell includes cmdlets that can set properties, create new items, and perform a wide range of other actions. Let’s start by examining the Set-SPSite cmdlet. You can use this cmdlet to configure a range of properties on a specific site collection.

Type the following command, and then press ENTER:

Set-SPSite –Identity http://intranet.contoso.com –SecondaryOwnerAlias CONTOSO\alexd 



1. To confirm that the site settings have changed, launch the SharePoint site’s Central Administration Web site. Click Start, then click SharePoint 2013 Products, and then click SharePoint 2013 Central Administration.
2. On the Central Administration home page, click the Application Management heading.
3. Under Site Collections, click Change site collection administrators.
4. On the Site Collection Administrators page, make the following changes:
5.  Change the Site Collection to intranet.contoso.com.
6. Verify that AlexD has been added as a secondary site collection administrator.



On a single, isolated SharePoint site, it may be faster to set the secondary site collection administrator through the Central Administration user interface.

However, let’s say you want to add a secondary site collection administrator to over two hundred (200) site collections. Rather than configuring hundreds of site collections individually in the Central Administration interface, you can use Set-SPSite to create a PowerShell script that loops through the site collections and change the site collection administrator on each one.

In the second part of this task, let’s take a look at to use Windows PowerShell to create new sites.

7. Switch back to the SharePoint 2013 Management Shell.
8. Type the following command, and press ENTER:

New-SPSite –Url http://intranet.contoso.com/sites/powershell –OwnerAlias 
CONTOSO\Administrator -Name "PowerShell Site" -Template STS#0 

       Note: If you do not specify a template in this step, you will be directed to a template selection page when you browse to the site. This particular cmdlet may take up to five (5) minutes to complete. To continue with this HOL and move to Exercise 2, open a new Windows PowerShell Management window.



9. When the command returns, switch to the browser window and browse to http://intranet.contoso.com/sites/powershell to verify that a new team site has been created at the URL. You may need to confirm your identity before accessing the site.



10. Optionally, you could also use the following cmdlet in Windows PowerShell sample to return a list of sites on http://intranet.contoso.com and confirm that the site has been added:

Get-SPSite http://intranet.contoso.com/sites/* 



In this article, you learned configure your SharePoint 2013 Windows PowerShell environment. You also learned the basics of retrieving information from the server farm and some of the basic, most commonly-used Get- cmdlets. You began working with feature management cmdlets in Windows PowerShell, and you also learned how to create site settings and set the site properties using Windows Powershell.

                                                                                                               ==>> KUMAR NUGALAPU
                                                                                                                         Senior Consultant

No comments:

Post a Comment