Web Part Gallery List items return empty in Powershell
-
11-12-2020 - |
문제
I get null returned when I run this code
$web = Get-SPWeb "http://siteurl"
$webPartGallery = $web.Lists["Web Part Gallery"]
$webpart=$webPartGallery.Items | ? { $_.Title -eq "webpartname"} #returns null
I check my Web part gallery there are many webparts but this code returns null for me. What is it that I am doing wrong?
Thanks!
해결책
Try below code:
$spSiteCollection = Get-SPWeb "http://siteurl"
$wpCatlog =[Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog
$spList = $spSiteCollection.GetCatalog([Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog)
foreach ($spItem in $spList.Items)
{
if($spItem.Title.Contains("webpartname"))
{
}
}
제휴하지 않습니다 sharepoint.stackexchange