From dd79e85725971af9fcabdb0c3ecb7f76e54a5179 Mon Sep 17 00:00:00 2001 From: Torsten Brendgen Date: Sun, 19 Jul 2026 23:33:47 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20=C3=9Cberpr=C3=BCfung=20der=20Share?= =?UTF-8?q?Point=20PowerShell-Komponenten=20hinzu=20und=20verbessere=20die?= =?UTF-8?q?=20Fehlerbehandlung=20in=20den=20Skripten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployment/add-megamenu.ps1 | 18 ++++++++++++++---- deployment/test-megamenu-site-scope.ps1 | 12 +++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/deployment/add-megamenu.ps1 b/deployment/add-megamenu.ps1 index b0da6d8..65c6e25 100644 --- a/deployment/add-megamenu.ps1 +++ b/deployment/add-megamenu.ps1 @@ -15,25 +15,35 @@ param( [string]$Description = 'MSFT-Custom-Solution:MegaMenu' ) -Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null +if (-not (Get-Command -Name Get-SPSite -ErrorAction SilentlyContinue)) { + if (Get-Module -ListAvailable -Name Microsoft.SharePoint.PowerShell) { + Import-Module Microsoft.SharePoint.PowerShell -DisableNameChecking + } + elseif (Get-PSSnapin -Registered -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) { + Add-PSSnapin Microsoft.SharePoint.PowerShell + } + else { + throw 'Die SharePoint PowerShell-Komponenten wurden nicht gefunden. Bitte in der SharePoint Management Shell ausfuehren.' + } +} $componentId = [Guid]'c0abbffb-355d-4d4e-bd38-9e15fb811506' $legacyComponentId = [Guid]'abc3361f-bb2d-491f-aba3-cd51c19a299b' $location = 'ClientSideExtension.ApplicationCustomizer' $configurationProperty = 'PortalSettings.MegaMenu.Configuration' -$properties = @{ +$properties = [string](@{ termSetName = $TermSetName termSetId = $TermSetId cacheMinutes = $CacheMinutes debug = [bool]$EnableDebug.IsPresent -} | ConvertTo-Json -Depth 10 -Compress +} | ConvertTo-Json -Depth 10 -Compress) $site = Get-SPSite -Identity $SiteUrl try { $rootWeb = $site.RootWeb - $rootWeb.AllProperties[$configurationProperty] = $properties + $rootWeb.AllProperties[$configurationProperty] = [string]$properties $rootWeb.Update() $siteActions = @( diff --git a/deployment/test-megamenu-site-scope.ps1 b/deployment/test-megamenu-site-scope.ps1 index b2259a7..d6c2f55 100644 --- a/deployment/test-megamenu-site-scope.ps1 +++ b/deployment/test-megamenu-site-scope.ps1 @@ -5,7 +5,17 @@ param( [string]$Description = 'MSFT-Custom-Solution:MegaMenu' ) -Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null +if (-not (Get-Command -Name Get-SPSite -ErrorAction SilentlyContinue)) { + if (Get-Module -ListAvailable -Name Microsoft.SharePoint.PowerShell) { + Import-Module Microsoft.SharePoint.PowerShell -DisableNameChecking + } + elseif (Get-PSSnapin -Registered -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) { + Add-PSSnapin Microsoft.SharePoint.PowerShell + } + else { + throw 'Die SharePoint PowerShell-Komponenten wurden nicht gefunden. Bitte in der SharePoint Management Shell ausfuehren.' + } +} $componentId = [Guid]'c0abbffb-355d-4d4e-bd38-9e15fb811506' $legacyComponentId = [Guid]'abc3361f-bb2d-491f-aba3-cd51c19a299b'