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.
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.
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.
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.
Name myAction script Sequence Scope Site
So here is the workaround. I check this in my system as well. This working fine as expected.
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.
Set‑PnPMasterPage" pretty easy and very straightforward. I am not going to deep dive into this chapter in more details you can go through the documentation.
PS:MasterPageServerRelativeUrl sites projects _catalogs masterpage oslo.master
PS:MasterPageServerRelativeUrl sites projects _catalogs masterpage oslo.master CustomMasterPageServerRelativeUrl sites projects _catalogs masterpage oslo.master
Enable/Disable the Minimal download strategy