Add-PnPCustomAction

Adds a custom action

Syntax

Add-PnPCustomAction
   -Name <String>
                      -Title <String>
                      -Location <String>
                      -ClientSideComponentId <GuidPipeBind>
                      [-RegistrationId <String>]
                      [-RegistrationType <UserCustomActionRegistrationType>]
                      [-Scope <CustomActionScope>]
                      [-ClientSideComponentProperties <String>]
                      [-Web <WebPipeBind>]
                      [-Connection <SPOnlineConnection>]
Add-PnPCustomAction
   -Name <String>
                      -Title <String>
                      -Description <String>
                      -Group <String>
                      -Location <String>
                      [-Sequence <Int>]
                      [-Url <String>]
                      [-ImageUrl <String>]
                      [-CommandUIExtension <String>]
                      [-RegistrationId <String>]
                      [-Rights <PermissionKind[]>]
                      [-RegistrationType <UserCustomActionRegistrationType>]
                      [-Scope <CustomActionScope>]
                      [-Web <WebPipeBind>]
                      [-Connection <SPOnlineConnection>]

Description

Adds a user custom action to a web or sitecollection.

Examples

------------------EXAMPLE 1------------------

$cUIExtn = "<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.List.Share.Controls._children""><Button Id=""Ribbon.List.Share.GetItemsCountButton"" Alt=""Get list items count"" Sequence=""11"" Command=""Invoke_GetItemsCountButtonRequest"" LabelText=""Get Items Count"" TemplateAlias=""o1"" Image32by32=""_layouts/15/images/placeholder32x32.png"" Image16by16=""_layouts/15/images/placeholder16x16.png"" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandler Command=""Invoke_GetItemsCountButtonRequest"" CommandAction=""javascript: alert('Total items in this list: '+ ctx.TotalListItems);"" EnabledScript=""javascript: function checkEnable() { return (true);} checkEnable();""/></CommandUIHandlers></CommandUIExtension>"

Add-PnPCustomAction -Name 'GetItemsCount' -Title 'Invoke GetItemsCount Action' -Description 'Adds custom action to custom list ribbon' -Group 'SiteActions' -Location 'CommandUI.Ribbon' -CommandUIExtension $cUIExtn

Adds a new custom action to the custom list template, and sets the Title, Name and other fields with the specified values. On click it shows the number of items in that list. Notice: escape quotes in CommandUIExtension.

------------------EXAMPLE 2------------------

Add-PnPCustomAction -Title "CollabFooter" -Name "CollabFooter" -Location "ClientSideExtension.ApplicationCustomizer" -ClientSideComponentId c0ab3b94-8609-40cf-861e-2a1759170b43 -ClientSideComponentProperties "{`"sourceTermSet`":`"PnP-CollabFooter-SharedLinks`",`"personalItemsStorageProperty`":`"PnP-CollabFooter-MyLinks`"}

Adds a new application customizer to the site. This requires that an SPFX solution has been deployed containing the application customizer specified.

Parameters

-ClientSideComponentId

The Client Side Component Id of the custom action

Only applicable to: SharePoint Online, SharePoint Server 2019

Type:GuidPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ClientSideComponentProperties

The Client Side Component Properties of the custom action. Specify values as a json string : "{Property1 : 'Value1', Property2: 'Value2'}"

Only applicable to: SharePoint Online, SharePoint Server 2019

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-CommandUIExtension

XML fragment that determines user interface properties of the custom action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Description

The description of the custom action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Group

The group where this custom action needs to be added like 'SiteActions'

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ImageUrl

The URL of the image associated with the custom action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Location

The actual location where this custom action need to be added like 'CommandUI.Ribbon'

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Name

The name of the custom action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-RegistrationId

The identifier of the object associated with the custom action.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-RegistrationType

Specifies the type of object associated with the custom action

Type:UserCustomActionRegistrationType
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Rights

A string array that contain the permissions needed for the custom action

Type:PermissionKind[]
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Scope

The scope of the CustomAction to add to. Either Web or Site; defaults to Web. 'All' is not valid for this command.

Type:CustomActionScope
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Sequence

Sequence of this CustomAction being injected. Use when you have a specific sequence with which to have multiple CustomActions being added to the page.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Title

The title of the custom action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Url

The URL, URI or ECMAScript (JScript, JavaScript) function associated with the action

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type:WebPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False