0

嗨,我正在尝试计算我在 SahrePoint 农场中的所有 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
}
}

有人可以建议吗?再次,这是我第一次尝试做事情编程!

谢了。

4

1 回答 1

3

尝试在 SharePoint 命令行管理程序中运行以下 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"

    }

}
于 2013-12-26T23:30:32.477 回答