Skip to main content

Office 365 & PNP PowerShell 2013 : Branding

The PNP branding section you can create custom action like link in the ribbon and other locations as well. For that you need to understand the Ribbon XML.

You can check the following links to know about the ribbon xml. 

  1. Adding a Button to the Server Ribbon`
  2. Add a custom ribbon to your sharepoint site
Now let’s do some practical work. To create the ribbon with PNP powershell, I am going to use the Add‑PnPCustomAction.

To get the all custom actions you need to use the Get‑PnPCustomAction command.

And to remove the custom action we get use the above method to get the all the custom action and delete all the custom action just loop over the collection use the Remove‑PnPCustomAction



In this example, I am going to use the CSV file to read the information and create the Ribbon based on the configuration.



Here is the CSV files for both operation are identical only one different in Action column ‘Del’ and ‘Add’ for distinguish the operation.


The code for cover the above mentioned custom ribbon example. The csv files for as name suggest "BrandingConfig_Add.csv"  for add action and "BrandingConfig_Del.csv" for get the collection and based on the title delete the item.




Get and Set the Home Page

With the help of these two method "Get‑PnPHomePage" and "Set‑PnPHomePage" you can get and set the page of your web. 

Imagine in you migration project you have various site URL and you need to identify the home page of 100 sites this method very handy and you quickly find the home page. 

Also you can write the quick utility to generate the report in the CSV file and vise versa you have 100 site in SharePoint and you need to set the home page. 

You can quickly write the script. here is the Utility. 



Working with JavaScript Block and links

So In this branding section PNP provide you give you handy Cmdlets that help you to add the JavaScript links as well as JavaScript block code. 

Here is the below commands that allows you to add and remove the JavaScript Links as well as the code blocks. 


I tried the code that provided in the example documentation. When I used the same code its not work either at my end. Here is the result of this code.

you can use the "Get‑PnPJavaScriptLink" for return the both script block ("Add‑PnPJavaScriptBlock") and script links "Add‑PnPJavaScriptLink". 

I tried both methods to add the "script block" and link to inject the custom script. In this example I am just give you example how we can add the script block. I faced issue while working with this.

I tried the example mentioned on the documentation, I got the below mentioned result. we do not include the script tag as well as we need to create one variable and assign this alert to this variable. 
Add-PnPJavaScriptBlock -Name myAction -script '<script>Alert("This is my Script block");</script>' -Sequence 9999 -Scope Site

Here is the Output of the. It break the other JavaScript as well. 


So here is the workaround. I check this in my system as well. This working fine as expected.



To remove the Links we can use the Remove-PNPJavaScriptLink method as mentioned in the screenshot.



So here is the full git hub gist. Just need to put the reference of your DLL and do the needful. 


------
------

Working with master pages 

So to set and the master page for your site/portal. In PnP cmdlets there are two command that going to help you to set the custom master page and default master page of your site. 


The cmdlets  "Get‑PnPMasterPage" and "Set‑PnPMasterPagepretty easy and very straightforward. I am not going to deep dive into this chapter in more details you can go through the documentation. 


Get-PnPMasterPage [-Web <WebPipeBind>]


PS:> Set-PnPMasterPage -MasterPageServerRelativeUrl /sites/projects/_catalogs/masterpage/oslo.master


PS:> Set-PnPMasterPage -MasterPageServerRelativeUrl /sites/projects/_catalogs/masterpage/oslo.master -CustomMasterPageServerRelativeUrl /sites/projects/_catalogs/masterpage/oslo.master

Enable/Disable the Minimal download strategy 

This cmdlets allows you to enable/disable the minimal download strategy for your current site collection "Set‑PnPMinimalDownloadStrategy"



PS:> Set-PnPMinimalDownloadStrategy -Off


PS:> Set-PnPMinimalDownloadStrategy -On

Comments

Popular posts from this blog

SharePoint RPC Protocols Examples Using OWSSVR.DLL

What is SharePoint RPC Protocols? Part 1 This reference includes information about the methods and usage of SharePoint Foundation Remote Procedure Call (RPC) protocol. This protocol can be used in Win32-based applications or in ASPX applications to make HTTP POST requests to the server. Methods in this protocol that do not modify the contents of the database can also be used in URL protocol to make HTTP GET requests. Definition taken from http://msdn.microsoft.com/en-us/library/ms448359.aspx You will find the OWSSVR.DLL in SharePoint 2010 Server Physical Path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI and MOSS C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI OWSSVR.DLL List of commands DialogView  Display ExportList GetProjSchema GetUsageBlob HitCounter RenderView To read more about the OWSSVR.DLL command Please read the URL Protocol from Microsoft Blog having a URL http://msdn.microsoft.com/en...

SharePoint 2013 Search Database Part 1

SharePoint 2013 Search architecture drastically change, as earlier in FS4SP 2010 we have 2 search applications “FASTContentSSA” and “FASTQuerySSA” and 7 total database in use. Following are the List of DB (FS4SP) FASTContentSSA Search Service Application DB Search Service Application Crawl Store DB Search Service Application Property Store DB FASTQuerySSA Search Service Application DB Search Service Application Crawl Store DB Search Service Application Property Store DB FASTSearchAdminDatabase : Fast Search Admin Database  In SharePoint 2013 search has only 1 Search Service application and 4 database in use. No property store database need any more, now the properties are directly stored inside the index component and all the index directly indexed to the physical system where FS4SP data comes from database as well as from the File system now data directly stored and indexed/ retried from the Physical disk because of this performance increase and search experien...

STS CryptographicException Error : Key set does not exist

Common mistakes Both SharePoint Site and SSO Site NOT running on the same application pool. Application pool identity user doesn’t have permission to access the certification.  Solution to this problem Set the same identity pool to  : 2. Be sure to grant rights to the certificate for the App Pool running the web service Start -> Run -> MMC File -> Add/Remove Snapin Add the Certificates Snap In Select Computer Account, then hit next Select Local Computer (the default), then click Finish On the left panel from Console Root, navigate to Certificates (Local Computer) -> Personal -> Certificates You're certificate will most likely be here. Right click on your certificate -> All Tasks -> Manage Private Keys Set you're private key settings here. Add app pool account Reset iis