Aktualisiere die README.md mit Anweisungen zur Registrierung des Field Customizers und Command Sets; füge neue Parameter für Command Set IDs in Enable- und Disable-ExpiryIndicator.ps1 hinzu; erstelle Test-ExpiryIndicatorRegistration.ps1 zur Überprüfung der Registrierung.

This commit is contained in:
Torsten Brendgen
2026-07-16 23:37:23 +02:00
parent dc6d9bf847
commit c450a5ed61
4 changed files with 99 additions and 17 deletions

View File

@@ -9,7 +9,9 @@ param(
[Parameter(Mandatory = $true)]
[string]$ExpiryFieldInternalName,
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde'
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde',
[Guid]$CommandSetComponentId = 'cd58f5d9-ffc8-4df7-a910-3054842d7abf'
)
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
@@ -22,23 +24,30 @@ $context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
try {
$list = $context.Web.Lists.GetByTitle($ListTitle)
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
$customActions = $list.UserCustomActions
$context.Load($list)
$context.Load($field)
$context.Load($customActions)
$context.ExecuteQuery()
if ($field.ClientSideComponentId -ne $FieldCustomizerComponentId) {
throw "Das Feld '$($field.InternalName)' ist nicht mit dem erwarteten ExpiryIndicator-Field-Customizer verbunden."
}
if ($PSCmdlet.ShouldProcess("$($list.Title)/$($field.InternalName)", 'ExpiryIndicator-Registrierungen entfernen')) {
if ($field.ClientSideComponentId -eq $FieldCustomizerComponentId) {
$field.ClientSideComponentId = [Guid]::Empty
$field.ClientSideComponentProperties = ''
$field.Update()
}
$customActions | Where-Object {
$_.Name -eq 'ExpiryIndicator.CommandSet' -or
$_.ClientSideComponentId -eq $CommandSetComponentId
} | ForEach-Object {
$_.DeleteObject()
}
if ($PSCmdlet.ShouldProcess("$($list.Title)/$($field.InternalName)", 'Field-Customizer-Verknüpfung entfernen')) {
$field.ClientSideComponentId = [Guid]::Empty
$field.ClientSideComponentProperties = ''
$field.Update()
$context.ExecuteQuery()
Write-Host "ExpiryIndicator-Verknüpfung wurde entfernt. Feld und Daten bleiben unverändert."
Write-Host 'ExpiryIndicator-Registrierungen wurden entfernt. Feld und Daten bleiben unverändert.'
}
}
finally {
$context.Dispose()
}