迴圈遍歷整個 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()
}
}
}