How to retrieve the URL of all Discussion Board in a web application using PowerShell?
1 Answer
Iterate through each site collection and web site to find a matching list.
This could take a while, and you will need appropraite permissions (e.g. a web application policy).
$discussionLibraryTemplateId = 108
# http://mirusp2010.blogspot.com.au/2013/03/list-template-id.html
# Find all site collections for a web app.
$sites = Get-SPSite -WebApplication http://tugboatTours.com
foreach($site in $sites)
{
// Iterate through each web site.
foreach($web in $site.AllWebs)
{
foreach($list in $web.Lists)
{
if ( (-not $list.Hidden) -and $list.BaseTemplate -eq $discussionLibraryTemplateId)
{
write-output $list.Name $list.Url
}
}
}
}
-
The C# (CSOM) version of this is here: sharepoint.stackexchange.com/questions/50907/…– RussellAug 30, 2016 at 9:05