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 the 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 the following script:

“Get-PnPCustomAction”

  • In the following example, it shows how you can get particular custom action and remove it from the 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 https://yoursite.sharepoint.com –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”);’

<#Get all custom action present under a site#>  
Get-PnPCustomAction  
<#Removes all custom actions that are ScriptLinks#>  
Get-PnPCustomAction -Scope All |? Location -eq ScriptLink | Remove-PnPCustomAction  

This solution is brought to you by our SharePoint professionals.

Softree Technology 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

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *