kwizcom banner advertisement

Get All List and Libraries Inventory of a SharePoint Site Collection using PowerShell

Requirement: Get All Lists and Libraries Inventory of a SharePoint Site Collection

PowerShell to Get Site Collection Inventory:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Site collection Variable
$SiteURL="http://intranet.crescent.com"
$ReportOutput="C:\SiteInventory.csv"

#Get the site collection
$Site = Get-SPSite $SiteURL

$ResultData = @()
#Ge All Sites of the Site collection
Foreach($web in $Site.AllWebs)
{
    Write-host -f Yellow "Processing Site: "$Web.URL
 
    #Get all lists - Exclude Hidden System lists
    $ListCollection = $web.lists | Where-Object  { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false)}

    #Iterate through All lists and Libraries
    ForEach ($List in $ListCollection)
    {
            $ResultData+= New-Object PSObject -Property @{
            'Site Title' = $Web.Title
            'Site URL' = $Web.URL
            'List-Library Name' = $List.Title
            'Item Count' = $List.ItemCount
            'Created By' = $List.Author.DisplayName
            'Last Modified' = $List.LastItemModifiedDate.ToString();
            'List URL' = "$($Web.Url)/$($List.RootFolder.Url)"
            } 
    } 
}

#Export the data to CSV
$ResultData | Export-Csv $ReportOutput -NoTypeInformation

Write-host -f Green "Report Generated Successfully at : "$ReportOutput

Report Output: 
Get All List and Libraries Inventory of a SharePoint Site Collection using PowerShell
Get All List and Libraries Inventory of a SharePoint Site Collection using PowerShell Get All List and Libraries Inventory of a SharePoint Site Collection using PowerShell Reviewed by Salaudeen Rajack on March 30, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.