문제

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")) 
    {           

    } 
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top