Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


SharePoint 2013

Applies to: SharePoint Foundation 2013, SharePoint Server 2013 Enterprise

Topic Last Modified: 2015-03-09

Returns all subsites that match the given criteria.

Get-SPWeb [[-Identity] <SPWebPipeBind>] [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Filter <ScriptBlock>] [-Limit <String>] [-Regex <SwitchParameter>] [-Site <SPSitePipeBind>] [-WhatIf [<SwitchParameter>]]

The Get-SPWeb cmdlet returns all subsites that match the scope given by the Identity parameter. All subsites that meet the criteria are returned.

The Identity can be either the full URL or a relative path. If you specify a relative path, you must also specify the Site parameter to identify the site collection from which to return the subsite.

The Identity parameter also supports providing a partial URL that ends in a wildcard character (*). All subsites that match this partial URL for the specified scope are returned. Additionally, if the Regex parameter is provided, the Identity parameter is treated as a regular expression and any subweb with a URL provided in the given scope that matches the expression is returned.

The Filter parameter is a server-side filter for certain subsite properties that are stored in the content database; without the Filter parameter, filtering on these properties is a slow process. These subsite properties are Template and Title. The Filter parameter is a script block that uses the same syntax as a Where-Object statement, but is run server-side for faster results.

It is important to note that every site collection returned by the Get-SPWeb cmdlet is automatically disposed of at the end of the pipeline. To store the results of Get-SPWeb in a local variable, the Start-SPAssignment and Stop-SPAssignment cmdlets must be used to avoid memory leaks.

SharePoint Management Shell


Parameter Required Type Description




Specifies the name or full or partial URL of the subsite. If you use a relative path, you must specify the Site parameter.

A valid URL in the form http://server_name or a relative path in the form of /SubSites/MySubSite.




Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.




Prompts you for confirmation before executing the command. For more information, type the following command: get-help about_commonparameters




Specifies the server-side filter to use for the specified scope.

The type must be a valid filter in the form {filterName <operator> "filterValue"}.




Limits the maximum number of subsites to return. The default value is 200. To return all sites, enter ALL

The type must be a valid number greater than 0 or ALL.




Specifies the URL that is provided by the Identity parameter is treated as a regular expression.




Specifies the URL or GUID of the site collection from which to list subsites.

The type must be a valid URL, in the form of http://server_name; a GUID, in the form 1234-5678-9807, or an SPSite object.




Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters

--------------------EXAMPLE 1----------------------

Get-SPWeb -site http://sitename/sites/site1

This example returns all the subwebs in a given site collection.

--------------------EXAMPLE 2----------------------

Get-SPWeb -Site http://sitename/sites/site1  -filter {$_.Template -eq "STS#0"}

This example displays all subsites that use the "STS#0" template.

--------------------EXAMPLE 3----------------------

Start-SPAssignment -Global
$w = Get-SPWeb http://sitename
Stop-SPAssignment -Global

This example demonstrates how to save a subsite as a variable and to call object model methods on the SPAssignment object.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft