Skip to content

Instantly share code, notes, and snippets.

@BasantPandey
Last active July 18, 2017 17:10
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 BasantPandey/4b1b4db27161ea4bfac14a912ab974f7 to your computer and use it in GitHub Desktop.
Save BasantPandey/4b1b4db27161ea4bfac14a912ab974f7 to your computer and use it in GitHub Desktop.
Add‑PnPJavaScriptBlock, Add‑PnPJavaScriptLink, Get‑PnPJavaScriptLink and Remove‑PnPJavaScriptLink Methods with Example
Import-Module 'C:\Users\basantp\Documents\PNP Blog Section\Code\SharePointPnPPowerShell2013\SharePointPnP.PowerShell.2013.Commands.dll';
try {
$URL='<Please enter your url>'
Connect-PnPOnline -Url $URL -CurrentCredentials -ErrorAction Stop
Write-host "Site $URL connected"
#Working code
Add-PnPJavaScriptBlock -Name "myAction" -script ' var ABC = alert("This is my Script block");' -Sequence 20000 -Scope Site
# You can use the -Scope switch
# The mentioned example not work for me PNP https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/AddPnPJavaScriptBlock.md
# Add-PnPJavaScriptBlock -Name myAction -script '<script>Alert("This is my Script block");</script>' -Sequence 9999 -Scope Site
#$NPNLINKS= Get-PnPJavaScriptLink -Scope Site
#If more then one you need to loop the item and delete the entries one by one.
#Remove-PnPJavaScriptLink -Scope Site -Name $NPNLINKS.Name -Force
}
catch {
"error"
}
@BasantPandey
Copy link
Author

This is the part of the PNP Brandingl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment