- Easy Way to loop through the sharepoint 2010 custom lists/libraries and its content types using powershell script.
********** ********** ********** ********** ********** ********** **********
Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# Site declaration
set-variable -option constant -name url -value "http://<<Site collection URL>>/Sites/Sitename"
$site= new-object Microsoft.SharePoint.SPSite($url)
# loop through all site in the site collection,
# then through all lists / libraries in that site (filtering out everything but actual doc libs
foreach($web in $site.AllWebs)
{
Write-Host ($web.Name + " - Site Name ********** Starts Here ")
# INT Site Processing Starts here
if ($web.Name -eq "<<SubSite Name>>")
{
# 1 loop
$site.AllWebs | Foreach-Object {
# 2 loop
$_.Lists | Where { ($_.BaseType -eq "DocumentLibrary") -and ($_.BaseTemplate -notmatch "Catalog") } | Foreach-Object {
# Individual Library level Starts here
if ($_.Title -eq "<<Library Name>>")
{
Write-Host (" <<Library Name>> Library " + $_.Title + " - " + $_.BaseType + " - " + $_.BaseTemplate )
}
if ($_.Title -eq "<<Library Name>>")
{
Write-Host (" <<Library Name>> Library " + $_.Title + " - " + $_.BaseType + " - " + $_.BaseTemplate )
}
# Ends here
# $_.Update()
} # 2 Loop ends here
} # 1 Loop Ends here
} # If condition of INT Site Processing Ends Here
# foreach($web in $site.AllWebs) Ends here
}
********** ********** ********** ********** ********** ********** **********
No comments:
Post a Comment