Add And Remove Operation Of Custom Action In SharePoint Site Using PnP PowerShell

In this blog, we will see how we can add a custom action in SharePoint site using PnP PowerShell. Also, we will see how we can get particular custom action and remove it from SharePoint site using PnP PowerShell.

Add Custom Action:-

In the following example, I have added a personal action menu in my SharePoint site.

Get Particular Custom action and remove it from site:-

  • You can get all user custom action present under site using following script:


  • In the following example it shows how you can get particular custom action and remove it from SharePoint site. In this particular example it removes all custom actions that are ScriptLinks:

“Get-PnPCustomAction -Scope All |? Location -eq ScriptLink | Remove-PnPCustomAction”

Connect-PnPOnline –Url –Credentials (Get-Credential)

<#Add user custom action in your SharePoint site.

Here it adds my custom action under personal action menu#>

Add-PnPCustomAction -Name ‘MyCustomActionMenu’ -Title ‘My Custom Menu’ -Description ‘Adds custom action to personal action menu’ -Group ‘PersonalActions’ -Location ‘Microsoft.SharePoint.StandardMenu’ -Sequence 3010 -Url ‘javascript:alert(“My custom action menu”);’

&amp;lt;#Get all custom action present under a site#&amp;gt;

&amp;lt;#Removes all custom actions that are ScriptLinks#&amp;gt;
Get-PnPCustomAction -Scope All |? Location -eq ScriptLink | Remove-PnPCustomAction

This solution is brought to you by our SharePoint professionals.

Softree Consulting employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.

Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best

Softree Consulting is an award-winning SharePoint consultancy that has been working with clients from across the globe to transform workplaces with tools and platforms from Microsoft technology. As a widely recognized organization, we are commonly approached to incorporate technical excellence and innovative design into all our customer actions.....

Site Footer