feat: update to version 2.1.0 with central site collection configuration and inheritance support
This commit is contained in:
@@ -24,10 +24,14 @@ $context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
|
||||
try {
|
||||
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
||||
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
||||
$rootWeb = $context.Site.RootWeb
|
||||
$customActions = $list.UserCustomActions
|
||||
$webCustomActions = $context.Web.UserCustomActions
|
||||
$context.Load($list)
|
||||
$context.Load($field)
|
||||
$context.Load($context.Web)
|
||||
$context.Load($rootWeb)
|
||||
$context.Load($rootWeb.AllProperties)
|
||||
$context.Load($customActions)
|
||||
$context.Load($webCustomActions)
|
||||
$context.ExecuteQuery()
|
||||
@@ -41,6 +45,28 @@ try {
|
||||
$field.ClientSideComponentProperties = ''
|
||||
$field.Update()
|
||||
|
||||
$bindingsKey = 'PortalSettings.ExpiryIndicator.Bindings'
|
||||
$bindings = @()
|
||||
$existingBindingsJson = [string]$rootWeb.AllProperties[$bindingsKey]
|
||||
if (-not [string]::IsNullOrWhiteSpace($existingBindingsJson)) {
|
||||
try {
|
||||
$bindings = @($existingBindingsJson | ConvertFrom-Json)
|
||||
}
|
||||
catch {
|
||||
$bindings = @()
|
||||
}
|
||||
}
|
||||
$webUrl = $context.Web.Url.TrimEnd('/')
|
||||
$listId = $list.Id.ToString('D')
|
||||
$bindings = @($bindings | Where-Object {
|
||||
-not (
|
||||
([string]$_.webUrl).TrimEnd('/').Equals($webUrl, [StringComparison]::OrdinalIgnoreCase) -and
|
||||
([string]$_.listId).Equals($listId, [StringComparison]::OrdinalIgnoreCase)
|
||||
)
|
||||
})
|
||||
$rootWeb.AllProperties[$bindingsKey] = (ConvertTo-Json -InputObject @($bindings) -Compress -Depth 5)
|
||||
$rootWeb.Update()
|
||||
|
||||
$customActions | Where-Object {
|
||||
$_.Name -eq 'ExpiryIndicator.Classic.ScriptLink' -or
|
||||
$_.Name -eq 'ExpiryIndicator.Classic.Ribbon'
|
||||
|
||||
Reference in New Issue
Block a user