Get-SPWeb

返回符合给定标准的所有子网站。

语法

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

说明

Get-SPWeb cmdlet 返回符合 Identity 参数给定的范围的所有子网站。 所有符合标准的子网站都将返回。

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.

Filter 参数是存储在内容数据库中某些子网站属性的服务器端筛选器;没有 Filter 参数,对这些属性的筛选将是一个缓慢的过程。 这些子网站属性为 Template 和 Title。 Filter 参数是使用与 Where-Object 语句相同语法的脚本块,但它运行服务器端以更快速获得结果。

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 产品的 Windows PowerShell 的权限和最新信息,请参阅 SharePoint Server cmdlet

示例

--------------------示例 1----------------------

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

此示例返回给定网站集中的所有子网站。

--------------------示例 2----------------------

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

此示例显示使用 "STS#0" 模板的所有子网站。

--------------------示例 3----------------------

Start-SPAssignment -Global
$w = Get-SPWeb https://sitename
$w.set_SiteLogoUrl("https://PathToImage/test.jpg")
$w.Update()
Stop-SPAssignment -Global

此示例演示如何将子网站保存为变量和在 SPAssignment 对象上调用对象模型方法。

参数

-Confirm

执行命令前,看到确认提示。 有关详细信息,请键入以下命令:get-help about_commonparameters

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Filter

指定要用于指定范围的服务器端筛选器。

键入的值必须为 {filterName <operator>"filterValue"} 格式的有效筛选器。

Type:ScriptBlock
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Identity

指定子网站的完整或部分 URL 的名称。 如果使用相对路径,则必须指定 Site 参数。

有效的 URL,形式为 https://server_name,或相对路径,形式为 /SubSites/MySubSite。

Type:SPWebPipeBind
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Limit

限制要返回的子网站的最大数量。 默认值为 200。 若要返回所有网站,请输入 ALL 。

键入的值必须为大于 0 或 ALL 的有效数字。

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Regex

指定将 Identity 参数提供的 URL 视为正则表达式。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Site

指定从中列出子网站的网站集的 URL 或 GUID。

该类型必须是有效的 URL,其形式为 https://server_name:GUID、窗体 1234-5678-9807 或 SPSite 对象。

Type:SPSitePipeBind
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-工作分配

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.

Type:SPAssignmentCollection
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition