0
votes

Even after disabling and uninstalling a SharePoint feature along with uninstalling and removing SharePoint solution, the .webpart files are still getting listed in "Web Part Gallery".

I issued the commands in the following sequence:

Disable-SPFeature
Uninstall-SPFeature
Uninstall-SPSolution
Remove-SPSolution

I could still see that .webpart files are hanging around. Imagine that I know the web part file names (say abc.webpart), how can I clean them up (totally remove) using SharePoint PowerShell.

1

1 Answers

0
votes

This powershell should get you started (it's not production ready but will do the job)

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$camlQuery = '<Where><Eq><FieldRef Name="FileLeafRef" /><Value Type="Text">abc.webpart</Value></Eq>  </Where>'
$spQuery.Query = $camlQuery

$site = Get-SPSite -Identity "http://site-collection-url"
$webpartgallery = $site.GetCatalog( [Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog)
$webparts = $webpartgallery.GetItems($spQuery)
$webparts[0].Recycle()