Skip to content

Instantly share code, notes, and snippets.

@ypcode
Last active September 11, 2017 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ypcode/f0b8d980b2b8c2a7dd77b1f520634c86 to your computer and use it in GitHub Desktop.
Save ypcode/f0b8d980b2b8c2a7dd77b1f520634c86 to your computer and use it in GitHub Desktop.
# This script allows to associate a SPFx ListViewCommandSet extension to a list type (100)
######################################################################
# Due to some inconsistency in accepted Cmdlet arguments
# We need to work around it by updating manually the RegistrationId and RegistrationType values
# The ClientSideComponentProperties is required even if the extension don't need any property
######################################################################
# Target web URL
$targetWebUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
# Set the name of your custom action here
$customActionName = "MARK_AS_IMPORTANT"
# Copy here the value of your component Id. It can be found in the manifest file of your component in your SPFx solution
$componentId = "30fb80ad-539e-4e30-8fd7-dbd2fd4bf514"
######################################################################
Connect-PnPOnline $targetWebUrl
Add-PnPCustomAction -Name $customActionName -Title "Mark as Important" -ClientSideComponenId $componentId -ClientSideComponentProperties "{}" -Location "ClientSideExtension.ListViewComandSet.CommandBar"
$c = Get-PnPCustomAction | ?{$_.Name -eq $customActionName}
$c.RegistrationId = 100
$c.RegistrationType = [Microsoft.SharePoint.Client.UserCustomActionRegistrationType]::List
$c.Update()
Execute-PnPQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment