下面的代码在出现错误时继续执行,
foreach($url in Get-Content $urlsDir)
{
try
{
// do something
// declare X
}
catch
{
// write host or soemthing with exception
continue
}
finally
{
// dispose X
}
}
但是当我把这段代码放到RunWithElevatedPrivileges中时,它会在第一次出错时完全停止,不会继续执行,
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
# Iterate through all webs in a text file
foreach($url in Get-Content $urlsDir)
{
try
{
// do something
// declare X
}
catch
{
// write host or soemthing with exception
continue
}
finally
{
// dispose X
}
}
});
https://stackoverflow.com/questions/50622342
复制相似问题