Improve Your Technology

Just another blog for techology

Listing all Sites and Webs having a List

When I was working for one of the customer I come across a requirement to update a list properties at all sites and sub-sites. Before updating list details I would like to know all the webs having the list. For this requirement I thought of writing small windows program to generate a CSV file with all the data. But later realized we have PowerShell to do all the things that we can do with a console application. Then I have written below script. After completion of writing, I realized the smartness of PowerShell. It reduced my turnaround time.

$date = Get-Date

$outFile = “.\ListDetails.csv”

$webappurl = “”

$lists = @()

$webapp = Get-SPWebApplication $webappurl

$webapp.Sites | foreach-object{

$_.AllWebs | ForEach-Object{

$_.Lists | where-object {$_.Title -eq “MyUserList”} | foreach-object{

$list = New-Object System.Object

$list | Add-Member -MemberType NoteProperty -Name “Site Url” -Value $_.ParentWeb.Site.Url

$list | Add-Member -MemberType NoteProperty -Name “Web Url” -Value $_.ParentWeb.Url

$list | Add-Member -MemberType NoteProperty -Name “List Title” -Value $_.Title

$lists += $list




$lists | Export-Csv -NoTypeInformation -Path $outFile

The above script written for my requirement. You can create list object with all the properties that you want to capture. Once you created list object with required data you can export to csv file.

July 10, 2013 Posted by | Getting Lists, Power Shell, SharePoint 2010 | , , | Leave a comment