SPO : PowerShell to get Custom Actions in a Site Collection


[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Client”)
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Client.Runtime”)

$siteUrl = Read-Host -Prompt “Enter sitecollection url”
$username = Read-Host -Prompt “Enter user login name”
$password = Read-Host -Prompt “Enter user login password” -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)

# SharePoint Online
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials

$rootWeb = $ctx.Site
$ctx.Load($rootWeb)
$ctx.ExecuteQuery()
$caColl = $rootWeb.get_userCustomActions()
$ctx.Load($caColl)
$ctx.ExecuteQuery()

Write-Host
Write-Host ‘Total number of custom actions: ‘$caColl.Count
$count = 1
$caColl | ForEach-Object {
Write-Host $count’)’  $_.Name
$count++
}


Comments (0)

Skip to main content