diff --git a/installer/setup.ps1 b/installer/setup.ps1 index 8704c3b0..c4ee9e4d 100644 --- a/installer/setup.ps1 +++ b/installer/setup.ps1 @@ -416,78 +416,111 @@ try { Write-Header "Schritt 5: Outlook Add-in registrieren" -# Manifest-Katalog-Ordner einrichten -$catalogDir = Join-Path $InstallDir "manifest-catalog" -New-Item -ItemType Directory -Path $catalogDir -Force | Out-Null -Copy-Item -Path (Join-Path $InstallDir "manifest.xml") -Destination $catalogDir -Force +# Manifest-Datei vorbereiten +$manifestDir = Join-Path $InstallDir "manifest-catalog" +New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null +Copy-Item -Path (Join-Path $InstallDir "manifest.xml") -Destination $manifestDir -Force +$manifestFile = Join-Path $manifestDir "manifest.xml" -# Terminal Server erkennen -$isTerminalServer = $false -$rdRole = Get-WindowsFeature -Name "RDS-RD-Server" -ErrorAction SilentlyContinue -if ($rdRole -and $rdRole.Installed) { - $isTerminalServer = $true -} elseif ((Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "TSAppCompat" -ErrorAction SilentlyContinue).TSAppCompat -eq 1) { - $isTerminalServer = $true -} +# Outlook Add-ins koennen NICHT per Registry/Shared Folder Catalog registriert werden. +# Das funktioniert nur fuer Word/Excel/PowerPoint. +# Fuer Outlook gibt es zwei Wege: +# 1. Exchange Online PowerShell (New-App) - fuer Organisationen mit Exchange +# 2. Manuell ueber Outlook Web App (OWA) - fuer alle -if ($isTerminalServer) { - Write-Step "Terminal Server erkannt - registriere Add-in fuer alle Benutzer (HKLM)." -} +$registeredViaExchange = $false -# Outlook Classic: Shared Folder Catalog per Registry konfigurieren -# Terminal Server: HKLM (gilt fuer alle User), sonst HKCU -$outlookVersions = @("16.0", "15.0") -$registeredClassic = $false +Write-Host " Outlook Add-ins muessen ueber Exchange oder manuell registriert werden." -ForegroundColor Gray +Write-Host "" -foreach ($ver in $outlookVersions) { - # Pruefen ob diese Outlook-Version installiert ist - $outlookPath = "HKLM:\Software\Microsoft\Office\$ver\Outlook" - if (-not (Test-Path $outlookPath)) { - $outlookPath = "HKLM:\Software\WOW6432Node\Microsoft\Office\$ver\Outlook" - } +# Variante 1: Exchange Online PowerShell versuchen +$tryExchange = Read-Host "Haben Sie Exchange Online und moechten das Add-in per Exchange bereitstellen? (j/n)" - if (Test-Path $outlookPath) { - Write-Step "Outlook $ver (Classic) gefunden." +if ($tryExchange -eq "j") { + Write-Step "Pruefe Exchange Online PowerShell Modul ..." - $catalogId = [guid]::NewGuid().ToString("B") - - # Bei Terminal Server: in HKLM registrieren (gilt fuer alle User) - if ($isTerminalServer) { - $outlookRegPath = "HKLM:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs" - $catalogRegPath = Join-Path $outlookRegPath $catalogId - New-Item -Path $catalogRegPath -Force | Out-Null - New-ItemProperty -Path $catalogRegPath -Name "Url" -Value $catalogDir -PropertyType String -Force | Out-Null - New-ItemProperty -Path $catalogRegPath -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null - Write-Step "Add-in Katalog fuer alle Benutzer registriert (HKLM)." + # Modul pruefen/installieren + $exModule = Get-Module -ListAvailable -Name "ExchangeOnlineManagement" -ErrorAction SilentlyContinue + if (-not $exModule) { + Write-Warn "ExchangeOnlineManagement Modul nicht gefunden." + $installModule = Read-Host "Modul jetzt installieren? (j/n)" + if ($installModule -eq "j") { + try { + Install-Module -Name ExchangeOnlineManagement -Force -Scope CurrentUser + Write-Step "Modul installiert." + } catch { + Write-Err "Modul-Installation fehlgeschlagen: $_" + } } + } - # Immer auch in HKCU fuer den aktuellen User (Fallback / Einzelplatz) - $outlookRegPathUser = "HKCU:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs" - $catalogRegPathUser = Join-Path $outlookRegPathUser $catalogId - New-Item -Path $catalogRegPathUser -Force | Out-Null - New-ItemProperty -Path $catalogRegPathUser -Name "Url" -Value $catalogDir -PropertyType String -Force | Out-Null - New-ItemProperty -Path $catalogRegPathUser -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null + $exModule = Get-Module -ListAvailable -Name "ExchangeOnlineManagement" -ErrorAction SilentlyContinue + if ($exModule) { + try { + Import-Module ExchangeOnlineManagement - Write-Step "Add-in Katalog fuer Outlook Classic registriert." - $registeredClassic = $true + Write-Host "" + Write-Host " Es oeffnet sich ein Anmeldefenster fuer Exchange Online." -ForegroundColor Gray + Write-Host " Bitte mit einem Exchange-Administrator-Konto anmelden." -ForegroundColor Gray + Write-Host "" + + Connect-ExchangeOnline -ShowBanner:$false + + $manifestBytes = [System.IO.File]::ReadAllBytes($manifestFile) + + # Als Organisations-App bereitstellen (fuer alle Benutzer) + $orgApp = Read-Host "Fuer alle Benutzer der Organisation bereitstellen? (j/n)" + if ($orgApp -eq "j") { + New-App -OrganizationApp -FileData $manifestBytes -DefaultStateForUser Enabled | Out-Null + Write-Step "Add-in fuer alle Benutzer der Organisation bereitgestellt!" + } else { + # Nur fuer bestimmte Mailbox + $mailbox = Read-Host "E-Mail-Adresse des Benutzers" + New-App -Mailbox $mailbox -FileData $manifestBytes | Out-Null + Write-Step "Add-in fuer $mailbox bereitgestellt!" + } + + $registeredViaExchange = $true + Disconnect-ExchangeOnline -Confirm:$false -ErrorAction SilentlyContinue + + } catch { + Write-Err "Exchange-Registrierung fehlgeschlagen: $_" + Write-Warn "Das Add-in kann stattdessen manuell hinzugefuegt werden (siehe unten)." + } } } -if (-not $registeredClassic) { - Write-Warn "Outlook Classic nicht in der Registry gefunden." -} - -# Pruefen ob New Outlook installiert ist -$newOutlook = Get-AppxPackage -Name "Microsoft.OutlookForWindows" -ErrorAction SilentlyContinue -if ($newOutlook) { - Write-Step "Neues Outlook gefunden: Version $($newOutlook.Version)" - Write-Warn "Fuer das neue Outlook muss das Add-in manuell hinzugefuegt werden:" +# Variante 2: Manuelle Registrierung (Fallback / kein Exchange) +if (-not $registeredViaExchange) { + Write-Host "" + Write-Header "Add-in manuell in Outlook registrieren" + Write-Host " Das Add-in muss in Outlook manuell hinzugefuegt werden." -ForegroundColor White + Write-Host " Dies gilt fuer Outlook Classic UND das neue Outlook." -ForegroundColor White + Write-Host "" + Write-Host " Variante A - Ueber Outlook Web App:" -ForegroundColor Cyan + Write-Host " 1. Im Browser oeffnen: https://aka.ms/olksideload" -ForegroundColor White + Write-Host " 2. 'Meine Add-Ins' -> 'Benutzerdefinierte Add-Ins'" -ForegroundColor White + Write-Host " 3. 'Benutzerdefiniertes Add-In hinzufuegen' -> 'Aus Datei hinzufuegen'" -ForegroundColor White + Write-Host " 4. Datei waehlen: $manifestFile" -ForegroundColor Yellow + Write-Host "" + Write-Host " Variante B - Direkt in Outlook Classic:" -ForegroundColor Cyan + Write-Host " 1. Outlook Classic oeffnen" -ForegroundColor White + Write-Host " 2. Datei -> Info -> 'Add-Ins verwalten' (oeffnet sich im Browser)" -ForegroundColor White + Write-Host " 3. Weiter wie bei Variante A ab Schritt 2" -ForegroundColor White + Write-Host "" + Write-Host " Variante C - Direkt im neuen Outlook:" -ForegroundColor Cyan Write-Host " 1. Neues Outlook oeffnen" -ForegroundColor White Write-Host " 2. Einstellungen (Zahnrad) -> Add-Ins verwalten" -ForegroundColor White Write-Host " 3. 'Benutzerdefinierte Add-Ins' -> 'Aus Datei hinzufuegen'" -ForegroundColor White - Write-Host " 4. Datei waehlen: $catalogDir\manifest.xml" -ForegroundColor White -} else { - Write-Step "Neues Outlook nicht installiert (nur Classic erkannt)." + Write-Host " 4. Datei waehlen: $manifestFile" -ForegroundColor Yellow + Write-Host "" + + $openBrowser = Read-Host "Sideload-Seite jetzt im Browser oeffnen? (j/n)" + if ($openBrowser -eq "j") { + Start-Process "https://aka.ms/olksideload" + Write-Step "Browser geoeffnet. Bitte Add-in wie oben beschrieben hinzufuegen." + Write-Host " Manifest-Datei: $manifestFile" -ForegroundColor Yellow + } } # ============================================================ @@ -499,10 +532,11 @@ $installInfo = @{ localPort = $localPort taskName = $taskName installedAt = (Get-Date).ToString("o") - catalogDir = $catalogDir + manifestDir = $manifestDir manifestUrl = "https://localhost:$localPort" caThumbprint = $caCert.Thumbprint localhostThumbprint = $localhostCert.Thumbprint + registeredViaExchange = $registeredViaExchange } $installInfo | ConvertTo-Json | Set-Content (Join-Path $InstallDir "install-info.json") -Encoding UTF8 @@ -514,17 +548,16 @@ Write-Header "Installation abgeschlossen!" Write-Host " Installationsverzeichnis: $InstallDir" -ForegroundColor White Write-Host " Lokaler Server: https://localhost:$localPort" -ForegroundColor White -Write-Host " Manifest: $catalogDir\manifest.xml" -ForegroundColor White +Write-Host " Manifest: $manifestFile" -ForegroundColor White Write-Host "" -if ($registeredClassic) { - Write-Host " Outlook Classic: Add-in wurde automatisch registriert." -ForegroundColor Green - Write-Host " Outlook neu starten, dann 'Kontakt-Sync' im Ribbon suchen." -ForegroundColor Green -} - -if ($newOutlook) { - Write-Host "" - Write-Host " Neues Outlook: Bitte Add-in manuell hinzufuegen (siehe oben)." -ForegroundColor Yellow +if ($registeredViaExchange) { + Write-Host " Outlook Add-in wurde per Exchange bereitgestellt." -ForegroundColor Green + Write-Host " Es kann einige Minuten dauern bis es in Outlook erscheint." -ForegroundColor Green +} else { + Write-Host " [!] Add-in muss noch manuell in Outlook hinzugefuegt werden!" -ForegroundColor Yellow + Write-Host " Manifest-Datei: $manifestFile" -ForegroundColor Yellow + Write-Host " Oder im Browser: https://aka.ms/olksideload" -ForegroundColor Yellow } Write-Host "" diff --git a/installer/uninstall.ps1 b/installer/uninstall.ps1 index af4e25c4..9f9a94db 100644 --- a/installer/uninstall.ps1 +++ b/installer/uninstall.ps1 @@ -99,35 +99,25 @@ if (Test-Path $certInfoPath) { # Schritt 3: Outlook Add-in Registrierung entfernen # ============================================================ -Write-Header "Schritt 3: Outlook-Registrierung entfernen" +Write-Header "Schritt 3: Outlook Add-in Registrierung" -$outlookVersions = @("16.0", "15.0") -foreach ($ver in $outlookVersions) { - # HKCU (Einzelplatz / aktueller User) - $catalogBasePath = "HKCU:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs" - if (Test-Path $catalogBasePath) { - $catalogs = Get-ChildItem $catalogBasePath -ErrorAction SilentlyContinue - foreach ($catalog in $catalogs) { - $url = Get-ItemProperty -Path $catalog.PSPath -Name "Url" -ErrorAction SilentlyContinue - if ($url -and $url.Url -like "*StarfaceOutlookSync*") { - Remove-Item $catalog.PSPath -Recurse -Force - Write-Step "Outlook $ver Katalog-Registrierung entfernt (HKCU)." - } - } - } +# Pruefen ob per Exchange registriert +$installInfoPath = Join-Path $InstallDir "install-info.json" +$registeredViaExchange = $false +if (Test-Path $installInfoPath) { + $installInfo = Get-Content $installInfoPath -Raw | ConvertFrom-Json + $registeredViaExchange = $installInfo.registeredViaExchange -eq $true +} - # HKLM (Terminal Server / alle User) - $catalogBasePathLM = "HKLM:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs" - if (Test-Path $catalogBasePathLM) { - $catalogs = Get-ChildItem $catalogBasePathLM -ErrorAction SilentlyContinue - foreach ($catalog in $catalogs) { - $url = Get-ItemProperty -Path $catalog.PSPath -Name "Url" -ErrorAction SilentlyContinue - if ($url -and $url.Url -like "*StarfaceOutlookSync*") { - Remove-Item $catalog.PSPath -Recurse -Force - Write-Step "Outlook $ver Katalog-Registrierung entfernt (HKLM)." - } - } - } +if ($registeredViaExchange) { + Write-Warn "Das Add-in wurde per Exchange bereitgestellt." + Write-Host " Um es dort zu entfernen:" -ForegroundColor Gray + Write-Host " 1. Exchange Online PowerShell: Get-App | Remove-App" -ForegroundColor Gray + Write-Host " 2. Oder im Microsoft 365 Admin Center" -ForegroundColor Gray +} else { + Write-Step "Das Add-in wurde manuell in Outlook hinzugefuegt." + Write-Host " Bitte manuell entfernen:" -ForegroundColor Gray + Write-Host " Outlook -> Add-Ins verwalten -> Add-In entfernen" -ForegroundColor Gray } # ============================================================