<#
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 13th Feb - 2017
Description -> This Script will generate a report to get all Site Collection Name, Created and associated Content database details across Web Application.
Path of csv file->$FileDirectory = "D:\contososMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
Site Collection Name --> "https://ms.contact.contoso.net/global/contoso"
#Call the function to get all Site Collection Name, Created and associated Content database Report across Web Application.
GetSiteColl_ContentDB_Created_Report "https://ms.contact.contosos.net" "D:\contosoMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function GetSiteColl_ContentDB_Created_Report($WebAPPUrl, $FileDirectory)
{
# Get All Site Collection from Web Application
$SiteCollUrl =Get-SPSite -WebApplication $WebAPPUrl -Limit all
# Creating Header TAB for Report
"Site Collection `t Content Database `t Created Site" | Out-File $FileDirectory
# Iterate foreach loop for site
foreach($Site in $SiteCollUrl)
{
# Iterate foreach loop for Content database which is associated with each site collection
foreach($contentDB in $Site.ContentDatabase)
{
#Write-Host $contentDB.Name
"$($Site.Url) `t$($contentDB.Name)`t $($Site.RootWeb.Created) "| Out-File $FileDirectory -Append
}
}
}
# Export Report in CSV file
GetSiteColl_ContentDB_Created_Report "https://ms.contact.contosos.net" "D:\contososMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 13th Feb - 2017
Description -> This Script will generate a report to get all Site Collection Name, Created and associated Content database details across Web Application.
Path of csv file->$FileDirectory = "D:\contososMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
Site Collection Name --> "https://ms.contact.contoso.net/global/contoso"
#Call the function to get all Site Collection Name, Created and associated Content database Report across Web Application.
GetSiteColl_ContentDB_Created_Report "https://ms.contact.contosos.net" "D:\contosoMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function GetSiteColl_ContentDB_Created_Report($WebAPPUrl, $FileDirectory)
{
# Get All Site Collection from Web Application
$SiteCollUrl =Get-SPSite -WebApplication $WebAPPUrl -Limit all
# Creating Header TAB for Report
"Site Collection `t Content Database `t Created Site" | Out-File $FileDirectory
# Iterate foreach loop for site
foreach($Site in $SiteCollUrl)
{
# Iterate foreach loop for Content database which is associated with each site collection
foreach($contentDB in $Site.ContentDatabase)
{
#Write-Host $contentDB.Name
"$($Site.Url) `t$($contentDB.Name)`t $($Site.RootWeb.Created) "| Out-File $FileDirectory -Append
}
}
}
# Export Report in CSV file
GetSiteColl_ContentDB_Created_Report "https://ms.contact.contosos.net" "D:\contososMW_Team\Shiv\SiteColl_DB_Created_TeamSite.CSV"
No comments:
Post a Comment