Create one CSV file with site collection url detials in "SiteCollectionName" columns.
Below is the power shell script to fetch the web part detials in Power Shell Grid View
Below is the power shell script to fetch the web part detials in Power Shell Grid View
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
function enumerateWebParts($Url) {
$site = new-object Microsoft.SharePoint.SPSite $Url
foreach($web in $site.AllWebs)
{
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))
{
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pages = $pWeb.PagesList
foreach ($item in $pages.Items)
{
$fileUrl = $webUrl +"/" + $item.File.Url
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$wps = $manager.webparts
$wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label="Type"}
}
}
else {
$pages = $null
$pages = $web.Lists["Site Pages"]
if ($pages)
{
foreach ($item in $pages.Items)
{
$fileUrl = $webUrl +"/" + $item.File.Url
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$wps = $manager.webparts
$wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label="Type"}
}
}
else {
}
} Write-Host"… completed processing" $web
}
}
#Get the CSV file and connect to the SharePoint list
$vessellist = import-csv -Path "C:\SiteCollectionName.csv"
$itemCount = $vessellist.Count;
$currentItem = 1;
foreach($item in $vessellist)
{
#Update the progress information
Write-Progress -Id 1 -ParentId 0 -Activity "Listing Data In CSV File" -PercentComplete (($currentItem/$itemCount)*100) -Status "Item $currentItem or $itemCount";
$currentItem++;
#Write the rows VESSEL_NAME column to the console
$row += enumerateWebParts($item.SiteCollectionName)
}
$row | Out-GridView
No comments:
Post a Comment