需要使用PowerShell统计服务器场中的WebbApps,SC和站点

时间:2013-12-26 17:54:46

标签: sharepoint powershell counting sitecollection

嗨我试着计算SahrePoint Farm中我所有的Web应用程序,一旦完成,我想要计算Web应用程序中的网站集和SC中的网站。我在编程方面是全新的这是我的第一个PwerShell脚本。

这是我尝试使用的代码。

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)             
{            
 Add-PSSnapin Microsoft.SharePoint.PowerShell            
}

$Get-SPWebApplication 

ForEach-Object{

      ForEach($SPWebApplication in $Get-SPWebApplication)
        {
        Get-SPSite -Limit All | 
        Select -ExpandProperty AllWebs | 
        ft url, Title, Created -auto | 
        out-string -width 1024 > c:\Sc.txt
}
}

有人可以建议吗?再次这是我第一次尝试编程的东西!

韩国社交协会

1 个答案:

答案 0 :(得分:3)

尝试在SharePoint Management Shell中运行以下PowerShell脚本,看看它是否符合您的需求:

Write-Host "Web Applications in Farm"
$WebApplications = Get-SPWebApplication
$WebApplications | Measure-Object | Format-List Count

ForEach($WebApplication in $WebApplications){
    Write-Host "Site Collections in the Web Application named " $WebApplication.Name
    $WebApplication.Sites | Measure-Object | Format-List Count

    ForEach($SiteCollection in $WebApplication.Sites){
        Write-Host "Webs (Sub-Sites) in the Site Collection with the URL " $SiteCollection.Url
        Write-Host "`nCount : " $SiteCollection.AllWebs.Count "`n`n`n"

    }

}