
Introduction
This post is intended to show how to query and list all Custom Action for a SharePoint Online Site Collection using CSOM.
Code
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
# 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
Copyright Notice: All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.