I need to loop through all site collection in a web app and I have to extract the list name called "Project Center" and list down all the list properties. Help required.
1 Answer
This should do it
$spWebApp = Get-SPWebApplication "http://myapplication.sharepoint.com/"
function getListProperties ($spweb)
{
foreach ($spList in $spweb.Lists | Where {$_.Title -eq "Project Center"})
{
Write-Host "List found in: $($spweb.Url)"
$spList.PSObject.Properties | Select-Object Name,Value
}
foreach ( $subweb in $spweb.Webs)
{
getListProperties $subweb
}
$spweb.Dispose()
}
foreach ($spSite in $spWebApp.Sites)
{
Write-Host "Looking in $($spSite.Url)..."
$rootWeb = $spSite.RootWeb
getListProperties $rootWeb
}
Don't forget to replace the spweb application URL with your SharePoint URL.
-
Am getting the following errrors: You cannot call a method on a null-valued expression.;;The term 'Get-SPWebApplication' is not recognized as the name of a cmdlet, function, script file, or operable program. ;;;'getListProperties' is not recognized as the name of a cmdlet. Am unable to solve these errors.(I have replaced the webapp url).– priyaJan 2, 2014 at 4:49
-
Make sure you are running this in the sharepoint management shell so that the sharepoint snapin is already loaded.– BlueBirdJan 2, 2014 at 13:51
-
Hi, the above code worked for me for retrieving list prperties using powershell. I need one more help for display the list properties by exporting it to .csv(export in excel). suggestions are welcome. thanks– priyaJan 7, 2014 at 10:57