【发布时间】:2013-09-25 00:02:52
【问题描述】:
如果我有以下情况
$webs = Get-SPWeb -Limit all -ErrorAction Stop
foreach($web in $webs)
{
Write-Host $web.SiteUsers.xml
}
我知道 .NET 中的相同代码会从 SPWeb.SiteUsers.xml 我的服务器上的一个站点获得异常。
实际的异常或原因并不重要 - 但运行上面的代码我没有看到任何传播或报告给 PowerShell 的异常,$web.SiteUsers.xml 只是在出错的站点上返回 null。
这是一个 powershell 的东西还是 Get-SPWeb 的一个怪癖?
【问题讨论】:
-
来自technet.microsoft.com/en-us/library/ff607807.aspx:
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.Therfor,一旦 cmdlet 完成,$webs 将成为已处置对象的集合。 -
@Eris Erm...是的。但这甚至还没有开始回答这个问题。
-
是否启用了
strict-mode?
标签: .net sharepoint powershell