Get a Specific Subsite (Web)

Scenario/Problem: You need to obtain a specific subsite reference.

Solution: Use the Get-SPWeb cmdlet to assign a variable the results using the -Identity parameter.

Providing the identity of the subsite with the Get-SPWeb cmdlet retrieves a specific subsite. Use this to assign the results to an object for use in other cmdlets, as shown in Listing 8.13.

Listing 8.13. Assigning a Variable to a Specific Subsite

$web = Get-SPWeb -Identity "http://sp2013/sites/sitecol/subsite"

Get PowerShell™ for SharePoint® 2013 How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.