Get-SPWeb
返回符合给定标准的所有子网站。
语法
Default (默认值)
Get-SPWeb
[[-Identity] <SPWebPipeBind>]
[-AssignmentCollection <SPAssignmentCollection>]
[-Confirm]
[-Filter <ScriptBlock>]
[-Limit <String>]
[-Regex]
[-Site <SPSitePipeBind>]
[-WhatIf]
[<CommonParameters>]
说明
Get-SPWeb cmdlet 返回符合 Identity 参数给定的范围的所有子网站。 所有符合标准的子网站都将返回。
Identity 可以为完整 URL,也可以为相对路径。 如果指定相对路径,则也必须指定 Site 参数以标识从中返回子网站的网站集。
Identity 参数还支持提供以通配符 (*) 结尾的部分 URL。 所有符合指定范围内此部分 URL 的子网站都将返回。 此外,如果提供了 Regex 参数,Identity 参数将被视为正则表达式,将返回给定范围内符合表达式的提供了 URL 的任何子网站。
Filter 参数是存储在内容数据库中某些子网站属性的服务器端筛选器;没有 Filter 参数,对这些属性的筛选将是一个缓慢的过程。 这些子网站属性为 Template 和 Title。 Filter 参数是使用与 Where-Object 语句相同语法的脚本块,但它运行服务器端以更快速获得结果。
需要注意的是,Get-SPWeb cmdlet 返回的每个网站集都在管道结束时自动释放。 要存储本地变量中 Get-SPWeb 的结果,必须使用 Start-SPAssignment 和 Stop-SPAssignment cmdlet 来避免内存泄漏。
有关适用于 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
C:\PS>$w = Get-SPWeb https://sitename
C:\PS>$w.set_SiteLogoUrl("https://PathToImage/test.jpg")
C:\PS>$w.Update()
Stop-SPAssignment -Global
此示例演示如何将子网站保存为变量和在 SPAssignment 对象上调用对象模型方法。
参数
-AssignmentCollection
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
管理对象以便正确进行处理。 使用 SPWeb 或 SPSite 等对象可能会耗用大量内存,而且在 Windows PowerShell 脚本中使用这些对象需要正确管理内存。 通过使用 SPAssignment 对象,可以将对象分配给变量,然后在不需要这些对象时对它们进行处理,以释放内存。 在使用 SPWeb、SPSite 或 SPSiteAdministration 对象时,如果不使用分配集合或 Global 参数,则会自动处理这些对象。
在使用 Global 参数时,所有对象均包含在全局存储中。 如果未立即使用对象,或未通过使用 Stop-SPAssignment 命令来处理对象,则可能会发生内存不足的情况。
参数属性
| 类型: | SPAssignmentCollection |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Confirm
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
执行命令前,看到确认提示。
有关详细信息,请键入以下命令:get-help about_commonparameters
参数属性
| 类型: | SwitchParameter |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | cf |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Filter
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
指定要用于指定范围的服务器端筛选器。
类型必须是 {filterName <运算符> “filterValue”} 格式的有效筛选器。
参数属性
| 类型: | ScriptBlock |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Identity
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
指定子网站的完整或部分 URL 的名称。 如果使用相对路径,则必须指定 Site 参数。
有效的 URL,形式为 https://server_name,或相对路径,形式为 /SubSites/MySubSite。
参数属性
| 类型: | SPWebPipeBind |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | 1 |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Limit
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
限制要返回的子网站的最大数量。 默认值为 200。 若要返回所有网站,请输入 ALL 。
键入的值必须为大于 0 或 ALL 的有效数字。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Regex
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
指定将 Identity 参数提供的 URL 视为正则表达式。
参数属性
| 类型: | SwitchParameter |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Site
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
指定从中列出子网站的网站集的 URL 或 GUID。
键入的值必须为有效的 URL,形式为 https://server_name;GUID,形式为 1234-5678-9807,或一个 SPSite 对象。
参数属性
| 类型: | SPSitePipeBind |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-WhatIf
适用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019
显示一条描述命令作用的消息,而不执行命令。
有关详细信息,请键入以下命令:get-help about_commonparameters
参数属性
| 类型: | SwitchParameter |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 无线 |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。