Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get List Of WPs Details From Web Apps To Site Collections
WhatsApp
Guest User
8y
4
k
0
0
25
Blog
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
People also reading
Membership not found