循环遍历整个 SharePoint 场
使用从 SharePoint Web 服务器执行的 PowerShell:
$wacoll = get-spwebapplication
foreach($wa in $wacoll){
if($wa.IsAdministrationWebApplication -eq $false){
foreach($site in $wa.Sites){
foreach($web in $site.AllWebs){
# your code here
$web.Dispose()
}
$site.Dispose()
}
}
}