Deleting webparts

Welcome Forums General PowerShell Q&A Deleting webparts

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 5 months ago.

  • Author
  • #6397

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by dbrs at 2012-09-05 04:46:11

    I have a script that does the uninstall of the webpart for me. I deactivate the feature, uninstall the feature, retract the solution and delete the solution, but the webpart still shows up in the gallery. How can I get the webpart out of the gallery with powershell?

    by ToddKlindt at 2012-09-07 14:14:52

    I don't know if this is the best way, there here is one way to get it:

    $web = get-spweb ''
    $wpg = $web.Lists["Web Part Gallery"]
    $wpg.items | select name, id

    Of course that first line shouldn't have all the formatting in it. It's just a regular get-spweb operation.

    That should get you the list of web parts. The SPListItem object has a delete method.

    Hope that helps.

    by poshoholic at 2012-09-07 14:40:55

    Todd, you can get rid of the extra formatting by placing your URL in single quotes inside of the PowerShell block.

    by ToddKlindt at 2012-09-07 14:44:14



    by dbrs at 2012-09-09 17:13:25

    thanks, that works, just needed to filter out the list a bit, I used this
    $wpg.items | where {$_.Name -match "ABC.*webpart"} | select name, id

The topic ‘Deleting webparts’ is closed to new replies.