<#
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 9th March Jan - 2017
Description -> THIS SCRIPT WILL GENERATE A REPORT TO GET Site collection URL, Site Collection Size, Sub Site URL and associated content database name.
Site Collection Name -->
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function GetUserAccessReport($WebAppURL, $FileUrl)
{
#Get All Site Collections of the WebApp
$SiteCollections = Get-SPSite -WebApplication $WebAppURL -Limit All
#Write CSV- TAB Separated File) Header
"Site Collection `t Site Coll Size in MB `t Sub Site `t Title `t Content DB " | out-file $FileUrl
#Loop through all site collections
foreach($Site in $SiteCollections)
{
# Get the Site Collection Size in MB.
$sizeinKB =$Site.Usage.Storage
$sizeinMB=$sizeinKB/1024/1024
$sizeinMB = [Math]::Round($sizeinMB,2)
Write-host $sizeinMB
#Loop through all content datbase
foreach($contentDB in $Site.ContentDatabase)
{
#Loop through all Sub Sites
foreach($Web in $Site.AllWebs)
{
"$($Site.RootWeb.Url)`t $($sizeinMB) `t $($Web.Url) `t $($Web.Title) `t $($contentDB) " | Out-File $FileUrl -Append
}
}
}
}
#Call the function to Check User Access
GetUserAccessReport "https://Abc.com" D:\Tech\Report.csv"
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 9th March Jan - 2017
Description -> THIS SCRIPT WILL GENERATE A REPORT TO GET Site collection URL, Site Collection Size, Sub Site URL and associated content database name.
Site Collection Name -->
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function GetUserAccessReport($WebAppURL, $FileUrl)
{
#Get All Site Collections of the WebApp
$SiteCollections = Get-SPSite -WebApplication $WebAppURL -Limit All
#Write CSV- TAB Separated File) Header
"Site Collection `t Site Coll Size in MB `t Sub Site `t Title `t Content DB " | out-file $FileUrl
#Loop through all site collections
foreach($Site in $SiteCollections)
{
# Get the Site Collection Size in MB.
$sizeinKB =$Site.Usage.Storage
$sizeinMB=$sizeinKB/1024/1024
$sizeinMB = [Math]::Round($sizeinMB,2)
Write-host $sizeinMB
#Loop through all content datbase
foreach($contentDB in $Site.ContentDatabase)
{
#Loop through all Sub Sites
foreach($Web in $Site.AllWebs)
{
"$($Site.RootWeb.Url)`t $($sizeinMB) `t $($Web.Url) `t $($Web.Title) `t $($contentDB) " | Out-File $FileUrl -Append
}
}
}
}
#Call the function to Check User Access
GetUserAccessReport "https://Abc.com" D:\Tech\Report.csv"
No comments:
Post a Comment