Remove Custom Action in SharePoint using PowerShell

Requirement:  Remove a Custom Action in SharePoint using PowerShell

Delete Custom Action using PowerShell in SharePoint:
Here is how to remove custom action in SharePoint 2013 using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Site variable
$CustomActionTitle ="Support Center"

Try {
    #Get the Web
    $Web = Get-SPWeb $SiteURL
    #Get the Custom Actions Filter by Title
    $CustomActions = $web.UserCustomActions | Where { $_.Title -eq $CustomActionTitle } | Select ID, Title

    If($CustomActions -ne $Null)
        #Delete custom action(s)
        $CustomActions | ForEach-Object {
            #Remove the custom action
            Write-Host -f Green "Custom Action '$($_.Title)' Deleted Successfully!"
        write-host -f Yellow "Custom Action '$CustomActionTitle' Doesn't Exist!"
} Catch {
    Write-Host -ForegroundColor Red "Error:" $_.Exception.Message

To delete all custom actions from the given scope, simply remove the "Where" class from the script!

Here is my related post on deleting custom action in SharePoint Online: How to Delete a Custom Action in SharePoint Online using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.