Get a complete report of all site collections

Hi all,

I used below script to get a summary of a site collection.But there is around 200 site collections in the web application.So i need to run these script for 200 times for all site collections.Is there any way to pass web application in the same script to iterate all site collections and get the summary of all site collections.Please help.

function Get-DocInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
foreach ($web in $site.AllWebs) {
foreach ($list in $web.Lists) {
if ($list.BaseType -ne DocumentLibrary) {
continue
}

foreach ($item in $list.Items) {
$data = @{
"Site" = $site.Url
"Web" = $web.Url
"list" = $list.Title
"Item URL" = $item.Url
"Item Title" = $item.Title
"Item Created" = $item["Created"]
"Item Modified" = $item["Modified"]
"Created By" = $item["Author"]
"Modified By" = $item["Editor"]

}
New-Object PSObject -Property $data
}
}
$web.Dispose();
}
$site.Dispose()
}


Get-DocInventory "http://tets.testabc.org/sites/abcd" | Export-Csv -NoTypeInformation -Path "C:\Users\Desktop\sitecollectionreport.csv"

please help. Thanks in advance.

Regards,

Praveen

May 26th, 2015 2:28am

Hi Praveen, this should be pretty easy.

All you have to do is get a collection of all site collections. Then pass every site collection to the function.

Something like this (I haven't tested it but should be okay):

$Sites = Get-SPSite -WebApplication "url of your web application" -Limit All foreach($s in $Sites) {
$a = $s.url

Get-DocInventory($a) } function Get-DocInventory([string]$siteUrl) { $site = New-Object Microsoft.SharePoint.SPSite $siteUrl foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseType -ne DocumentLibrary) { continue } foreach ($item in $list.Items) { $data = @{ "Site" = $site.Url "Web" = $web.Url "list" = $list.Title "Item URL" = $item.Url "Item Title" = $item.Title "Item Created" = $item["Created"] "Item Modified" = $item["Modified"] "Created By" = $item["Author"] "Modified By" = $item["Editor"] } New-Object PSObject -Property $data } } $web.Dispose(); } $site.Dispose() }

Free Windows Admin Tool Kit Click here and download it now
May 26th, 2015 2:34am

Hi nico,

Thanks for u r reply.I ran this script i got below error.

Get-SPSite : Limit parameter can only be a positive integer or a String 'All'.
At C:\Users\Desktop\sp13report.ps1:1 char:10
+ $Sites = Get-SPSite -WebApplication "https://abcd.xyz.org"
-Limit Al ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:
   SPCmdletGetSite) [Get-SPSite], SPCmdletException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

regards,

Praveen

May 26th, 2015 3:31am

Hi,

Sorry, try the script again (Changed Allwebs to All). Autocomplete did that for me :-)

Free Windows Admin Tool Kit Click here and download it now
May 26th, 2015 3:38am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics