Last active
July 18, 2017 17:10
-
-
Save BasantPandey/4b1b4db27161ea4bfac14a912ab974f7 to your computer and use it in GitHub Desktop.
Add‑PnPJavaScriptBlock, Add‑PnPJavaScriptLink, Get‑PnPJavaScriptLink and Remove‑PnPJavaScriptLink Methods with Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the part of the PNP Brandingl