Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Get all lists from sharepoint that match certain criteria

$
0
0

I am using this code (courtesy of Codeplex) to show all lists in a webapp.

--------------------------------------------------------------

param

(

[string] $URL,

[boolean] $WriteToFile = $true

) <o:p></o:p>

#Get
all lists in farm

Add-PSSnapin
Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue<o:p></o:p>

#Counter
variables


$webcount = 0

$listcount = 0<o:p></o:p>

if($WriteToFile
-eq $true)

{

$outputPath = Read-Host "Outputpath (e.g. C:\directory\filename.txt)"


}

if(!$URL)

{

#Grab all webs

$webs = (Get-SPSite -limit all | Get-SPWeb -Limit all -ErrorAction
SilentlyContinue)

}

else

{

$webs = Get-SPWeb $URL

}

if($webs.count -ge 1 -OR $webs.count -eq $null)

{

foreach($web in $webs)

{

#Grab all lists in the current web

$lists = $web.Lists

Write-Host "Website"$web.url -ForegroundColor Green

if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "Website
$($web.url)"}

foreach($list in $lists)

{

$listcount +=1

Write-Host " – "$list.Title

if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value " –
$($list.Title)"}

}

$webcount +=1

$web.Dispose()

}

#Show total counter for checked webs & lists

Write-Host "Amount of webs checked:"$webcount

Write-Host "Amount of lists:"$listcount

}

else

{

Write-Host "No webs retrieved, please check your permissions"
-ForegroundColor Red -BackgroundColor Black

}<o:p></o:p>

------------------------------------------------------

I need to set a filter to show me only lists that

  • have the word "workflowhistory"
  • have over 7000 items

I tried using the qualifier

| Where { ($_.item -like '*workflowhistory*')}    but no luck! 

Thanks again for help!


----------------------------


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>