SharePoint2013 Powershell script to get site Title, Site Owner, Site user count and usage

Powershell script to get site Title, Site Owner, Site user count and usage

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$wburl = Read-Host "Enter Web application URL "
$webApp = Get-SPWebApplication $wburl
$outputPath =Read-Host "Enter path to save results "
Add-Content -Path $outputPath -Value "Site Title,Site URL, Site Owner, UserCount,Usage in MB"
foreach ($SiteCollection in $webApp.Sites)
{
$url = $SiteCollection.Url
$webs = Get-SPWeb $URL
[boolean] $WriteToFile = $true
$weburl = $SiteCollection.OpenWeb()
$siteowner = ""
foreach ($siteAdmin in $weburl.SiteAdministrators)
{
$siteowner = $siteAdmin.LoginName + "|" + $siteowner
}
foreach($web in $webs)
{
#Grab all users in the site collections
$siteUserCnt = $web.AllUsers.Count
$Siteurl = $web.Url
$siteTitle = $web.Title
$site = Get-SPSite  $Siteurl

$siteusage = $site.Usage.Storage/1MB

Add-Content -Path $outputPath -Value "$siteTitle,$Siteurl,$siteowner,$siteUserCnt,$siteusage"
$web.Dispose()
}
}
posted @ 2014-07-01 23:10  大刀客  阅读(587)  评论(0编辑  收藏  举报