TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get List Of WPs Details From Web Apps To Site Collections
Guest User
Mar 23, 2017
3.8
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
This blog helps you to get the list of WPs details from Web apps to Site Collections.
Create a ps1 extension file and save it in your local path.
Change the highlighted part with your Web app URL.
function
enumerateWebParts($Url) {
$webApp = Get - SPWebApplication $Url# Get WebApplication URL
foreach($web
in
$webApp | Get - SPSite - Limit All | Get - SPWeb - Limit All)# foreach loop to iterate through all sites and webs of WebApplication {
if
([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))# Check
if
site is a publishing site {
$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
foreach($type
in
$wps)# loop through each type found $wps {
if
($type - like
"**"
)#
if
webpart $type - like KWizCom select webpart object {
$wps | select - object @ {
Expression = {
$pWeb.Url
};
Label =
"Web URL"
}, @ {
Expression = {
$fileUrl
};
Label =
"Page URL"
}, DisplayTitle, IsVisible, @ {
Expression = {
$type
};
Label =
"Type"
}
}
}
}
}
else
#
if
web is not a publishing site {
$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
foreach($type
in
$wps) {
if
($type - like
"**"
) {
$wps | select - object @ {
Expression = {
$Web.Url
};
Label =
"Web URL"
}, @ {
Expression = {
$fileUrl
};
Label =
"Page URL"
}, DisplayTitle, IsVisible, @ {
Expression = {
$type
};
Label =
"Type"
}
}
}
}
}
else
{}
}
Write - Host
"… completed processing"
$web
}
}
$row = enumerateWebParts('http:
//hvsp01:10641’) #call the enumerateWebParts function pass it the URL for the web application
$row | Out - GridView
Open Management Shell as an administrator.
Run PS script, using the path along with the file name in the management shell.
Here, the required output is given below.
You can filter the details in a more granular level whenever required.
Get List Of WPs Details
Web Apps
Site Collections
Next Recommended Reading
Get all Site Collections, Sites & Sub sites form Web Application in SharePoint 2010 using Powershell