How to list all Site Custom Actions using CSOM and PowerShell in Office 365

Introduction

This post is intended to show how to query and list all Custom Action for a SharePoint Online Site Collection using CSOM.

Code

# replace these details (also consider using Get-Credential to enter password securely as script runs)..
$username = "user@tenant.onmicrosoft.com"
$password = "pass"
$url = "https://tenant.sharepoint.com/sites/site"
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
# connect/authenticate to SharePoint Online and get ClientContext object..
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
$clientContext.Credentials = $credentials
if (!$clientContext.ServerObjectIsNull.Value)
{
Write-Host "Connected to SharePoint Online site: '$Url'" -ForegroundColor Green
}
$site = $clientContext.Site
$sca = $site.UserCustomActions;
$clientContext.Load($sca)
$clientContext.ExecuteQuery()
$sca

 

Author: José Quinto
Link: https://blog.josequinto.com/2016/06/01/how-to-list-all-site-custom-actions-using-csom-and-powershell-in-office-365/
Copyright Notice: All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.