Part 2: Customize SharePoint Online User Interface using JavaScript | CSOM | PowerShell

2016-11-02_12-42-56

This is a continuation of part 1 and we will cover about adding a custom action in site action of the web. Note: You can think about any solution. This blog post is to show an option in PowerShell and Client Side Object Model to customize the Site Actions of the web.

  1. To know Default Custom Action and Location ID’s – Navigate here.
  2. How to work with User Custom Action – Navigate here.

Here is the sample code to add a link in Site Actions!

#Choose the Location as Microsoft.SharePoint.SiteSettings
$UserCustomAction.Location = "Microsoft.SharePoint.SiteSettings"

#Choose the Group as SiteTasks (Site Actions)
$UserCustomAction.Group = "SiteTasks"

Site Actions Before

2016-11-02_12-30-44

Site Actions After

12

Full Code

Import-Module C:\Temp\SharePointOnlinePowerShell\Microsoft.SharePoint.Client.dll
$Admin = "Chendrayan@Contoso.onmicrosoft.com"
$Password = "Password01" | ConvertTo-SecureString -AsPlainText -Force 
$Context = [Microsoft.SharePoint.Client.ClientContext]::new("https://contoso.sharepoint.com/Sites/PublishingPortal")
$Context.Credentials = [Microsoft.SharePoint.Client.SharePointOnlineCredentials]::new($Admin,$Password)

$UserCustomAction = $Context.Web.UserCustomActions.Add()

#Choose the Location as Microsoft.SharePoint.SiteSettings
$UserCustomAction.Location = "Microsoft.SharePoint.SiteSettings"

#Choose the Group as SiteTasks (Site Actions)
$UserCustomAction.Group = "SiteTasks"

$UserCustomAction.Name = "Demo"
$UserCustomAction.Sequence = 1000
$UserCustomAction.Url = "http://www.bing.com"
$UserCustomAction.Title = "Search Bing"
$UserCustomAction.Update()

$Context.ExecuteQuery()

Enjoy PowerShell!

Published by

Chen V

I am a SharePoint 2010 IT Pro. My area of interests are Workflows, Automation, Office 365 , Identity and Access Management, PowerShell and Windows Servers.

Leave a Reply

Your email address will not be published. Required fields are marked *