Fix installer scripts: private key export, encoding, description
- Fix PrivateKey null error by using GetRSAPrivateKey() instead of .PrivateKey which is null for certs created with -Signer - Replace all Unicode characters (umlauts, arrows, emojis) with ASCII-safe alternatives so output renders correctly on any Windows console regardless of codepage - Add explanation in setup why Starface URL is needed (CA import) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c303461330
commit
60b44788fd
|
|
@ -4,8 +4,8 @@
|
||||||
Importiert das SSL-Zertifikat einer Starface-Anlage in den Windows-Zertifikatspeicher.
|
Importiert das SSL-Zertifikat einer Starface-Anlage in den Windows-Zertifikatspeicher.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Verbindet sich per SSL/TLS zur angegebenen Starface-Anlage, extrahiert das
|
Verbindet sich per SSL/TLS zur angegebenen Starface-Anlage, extrahiert das
|
||||||
Zertifikat und importiert es als vertrauenswürdig. Danach kann das Outlook
|
Zertifikat und importiert es als vertrauenswuerdig. Danach kann das Outlook
|
||||||
Add-in die Starface REST-API über HTTPS erreichen.
|
Add-in die Starface REST-API ueber HTTPS erreichen.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\import-cert.ps1 -StarfaceHost 192.168.1.100
|
.\import-cert.ps1 -StarfaceHost 192.168.1.100
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
|
|
@ -27,7 +27,7 @@ Write-Host " Starface-Zertifikat importieren" -ForegroundColor Cyan
|
||||||
Write-Host "============================================================" -ForegroundColor Cyan
|
Write-Host "============================================================" -ForegroundColor Cyan
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
Write-Host " Verbinde mit ${StarfaceHost}:${Port} ..." -ForegroundColor Green
|
Write-Host " [OK] Verbinde mit ${StarfaceHost}:${Port} ..." -ForegroundColor Green
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$tcpClient = New-Object System.Net.Sockets.TcpClient
|
$tcpClient = New-Object System.Net.Sockets.TcpClient
|
||||||
|
|
@ -35,7 +35,7 @@ try {
|
||||||
$sslStream = New-Object System.Net.Security.SslStream(
|
$sslStream = New-Object System.Net.Security.SslStream(
|
||||||
$tcpClient.GetStream(),
|
$tcpClient.GetStream(),
|
||||||
$false,
|
$false,
|
||||||
{ $true } # Alle Zertifikate akzeptieren für den Abruf
|
{ $true } # Alle Zertifikate akzeptieren fuer den Abruf
|
||||||
)
|
)
|
||||||
$sslStream.AuthenticateAsClient($StarfaceHost)
|
$sslStream.AuthenticateAsClient($StarfaceHost)
|
||||||
|
|
||||||
|
|
@ -46,13 +46,13 @@ try {
|
||||||
$tcpClient.Close()
|
$tcpClient.Close()
|
||||||
|
|
||||||
Write-Host " Zertifikat erhalten:" -ForegroundColor Green
|
Write-Host " Zertifikat erhalten:" -ForegroundColor Green
|
||||||
Write-Host " Subject: $($x509Cert.Subject)" -ForegroundColor White
|
Write-Host " Subject: $($x509Cert.Subject)" -ForegroundColor White
|
||||||
Write-Host " Aussteller: $($x509Cert.Issuer)" -ForegroundColor White
|
Write-Host " Aussteller: $($x509Cert.Issuer)" -ForegroundColor White
|
||||||
Write-Host " Gültig bis: $($x509Cert.NotAfter)" -ForegroundColor White
|
Write-Host " Gueltig bis: $($x509Cert.NotAfter)" -ForegroundColor White
|
||||||
Write-Host " Thumbprint: $($x509Cert.Thumbprint)" -ForegroundColor White
|
Write-Host " Thumbprint: $($x509Cert.Thumbprint)" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Prüfen ob bereits vorhanden
|
# Pruefen ob bereits vorhanden
|
||||||
$rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store(
|
$rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store(
|
||||||
[System.Security.Cryptography.X509Certificates.StoreName]::Root,
|
[System.Security.Cryptography.X509Certificates.StoreName]::Root,
|
||||||
[System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine
|
[System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine
|
||||||
|
|
@ -62,19 +62,19 @@ try {
|
||||||
$rootStore.Close()
|
$rootStore.Close()
|
||||||
|
|
||||||
if ($existing) {
|
if ($existing) {
|
||||||
Write-Host " Zertifikat ist bereits als vertrauenswürdig gespeichert." -ForegroundColor Yellow
|
Write-Host " Zertifikat ist bereits als vertrauenswuerdig gespeichert." -ForegroundColor Yellow
|
||||||
} else {
|
} else {
|
||||||
$rootStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
$rootStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
||||||
$rootStore.Add($x509Cert)
|
$rootStore.Add($x509Cert)
|
||||||
$rootStore.Close()
|
$rootStore.Close()
|
||||||
Write-Host " Zertifikat erfolgreich als vertrauenswürdig importiert!" -ForegroundColor Green
|
Write-Host " [OK] Zertifikat erfolgreich als vertrauenswuerdig importiert!" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host " Fehler: $_" -ForegroundColor Red
|
Write-Host " [X] Fehler: $_" -ForegroundColor Red
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Mögliche Ursachen:" -ForegroundColor Yellow
|
Write-Host " Moegliche Ursachen:" -ForegroundColor Yellow
|
||||||
Write-Host " - Starface nicht erreichbar (IP/Hostname prüfen)" -ForegroundColor Yellow
|
Write-Host " - Starface nicht erreichbar (IP/Hostname pruefen)" -ForegroundColor Yellow
|
||||||
Write-Host " - Falscher Port (Standard: 443)" -ForegroundColor Yellow
|
Write-Host " - Falscher Port (Standard: 443)" -ForegroundColor Yellow
|
||||||
Write-Host " - Firewall blockiert die Verbindung" -ForegroundColor Yellow
|
Write-Host " - Firewall blockiert die Verbindung" -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
#Requires -RunAsAdministrator
|
#Requires -RunAsAdministrator
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Setup-Script für Starface Outlook Sync Add-in.
|
Setup-Script fuer Starface Outlook Sync Add-in.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
- Fragt Starface-Host (für Zertifikat) und lokalen Port ab
|
- Fragt Starface-Host ab (zum Import des SSL-Zertifikats)
|
||||||
- Extrahiert das SSL-Zertifikat der Starface und importiert es als vertrauenswürdig
|
- Fragt lokalen Port ab fuer den Webserver
|
||||||
|
- Extrahiert das SSL-Zertifikat der Starface und importiert es als vertrauenswuerdig
|
||||||
- Erstellt eine lokale CA und ein localhost-Zertifikat
|
- Erstellt eine lokale CA und ein localhost-Zertifikat
|
||||||
- Installiert den lokalen HTTPS-Webserver als Windows-Dienst
|
- Installiert den lokalen HTTPS-Webserver als Windows Scheduled Task
|
||||||
- Registriert das Outlook Add-in
|
- Registriert das Outlook Add-in
|
||||||
Login-Daten werden NICHT benötigt - diese werden später im Add-in selbst
|
Login-Daten werden NICHT benoetigt - diese werden spaeter im Add-in selbst
|
||||||
in den Sync-Profilen konfiguriert.
|
in den Sync-Profilen konfiguriert.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
|
@ -32,15 +33,15 @@ function Write-Header($text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Step($text) {
|
function Write-Step($text) {
|
||||||
Write-Host " → $text" -ForegroundColor Green
|
Write-Host " [OK] $text" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Warn($text) {
|
function Write-Warn($text) {
|
||||||
Write-Host " ⚠ $text" -ForegroundColor Yellow
|
Write-Host " [!] $text" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Err($text) {
|
function Write-Err($text) {
|
||||||
Write-Host " ✗ $text" -ForegroundColor Red
|
Write-Host " [X] $text" -ForegroundColor Red
|
||||||
}
|
}
|
||||||
|
|
||||||
function Test-NodeJs {
|
function Test-NodeJs {
|
||||||
|
|
@ -67,7 +68,7 @@ function Import-StarfaceCert($host_, $port_) {
|
||||||
$sslStream = New-Object System.Net.Security.SslStream(
|
$sslStream = New-Object System.Net.Security.SslStream(
|
||||||
$tcpClient.GetStream(),
|
$tcpClient.GetStream(),
|
||||||
$false,
|
$false,
|
||||||
{ $true } # Alle Zertifikate akzeptieren für den Abruf
|
{ $true } # Alle Zertifikate akzeptieren fuer den Abruf
|
||||||
)
|
)
|
||||||
$sslStream.AuthenticateAsClient($host_)
|
$sslStream.AuthenticateAsClient($host_)
|
||||||
|
|
||||||
|
|
@ -79,7 +80,7 @@ function Import-StarfaceCert($host_, $port_) {
|
||||||
|
|
||||||
Write-Step "Zertifikat erhalten: $($x509Cert.Subject)"
|
Write-Step "Zertifikat erhalten: $($x509Cert.Subject)"
|
||||||
Write-Step "Aussteller: $($x509Cert.Issuer)"
|
Write-Step "Aussteller: $($x509Cert.Issuer)"
|
||||||
Write-Step "Gültig bis: $($x509Cert.NotAfter)"
|
Write-Step "Gueltig bis: $($x509Cert.NotAfter)"
|
||||||
|
|
||||||
# In den Trusted Root Store importieren
|
# In den Trusted Root Store importieren
|
||||||
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store(
|
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store(
|
||||||
|
|
@ -90,20 +91,20 @@ function Import-StarfaceCert($host_, $port_) {
|
||||||
$store.Add($x509Cert)
|
$store.Add($x509Cert)
|
||||||
$store.Close()
|
$store.Close()
|
||||||
|
|
||||||
Write-Step "Starface-Zertifikat als vertrauenswürdig importiert."
|
Write-Step "Starface-Zertifikat als vertrauenswuerdig importiert."
|
||||||
return $x509Cert
|
return $x509Cert
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Voraussetzungen prüfen
|
# Voraussetzungen pruefen
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
Write-Header "Starface Outlook Sync - Setup"
|
Write-Header "Starface Outlook Sync - Setup"
|
||||||
|
|
||||||
# Node.js prüfen und ggf. installieren
|
# Node.js pruefen und ggf. installieren
|
||||||
if (-not (Test-NodeJs)) {
|
if (-not (Test-NodeJs)) {
|
||||||
Write-Warn "Node.js ist nicht installiert."
|
Write-Warn "Node.js ist nicht installiert."
|
||||||
Write-Host " Node.js wird für den lokalen Webserver benötigt." -ForegroundColor Gray
|
Write-Host " Node.js wird fuer den lokalen Webserver benoetigt." -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
$installNode = Read-Host "Node.js jetzt automatisch herunterladen und installieren? (j/n)"
|
$installNode = Read-Host "Node.js jetzt automatisch herunterladen und installieren? (j/n)"
|
||||||
|
|
||||||
|
|
@ -139,17 +140,17 @@ if (-not (Test-NodeJs)) {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# PATH aktualisieren (MSI fügt Node.js zum System-PATH hinzu)
|
# PATH aktualisieren (MSI fuegt Node.js zum System-PATH hinzu)
|
||||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
# Aufräumen
|
# Aufraeumen
|
||||||
Remove-Item $msiPath -Force -ErrorAction SilentlyContinue
|
Remove-Item $msiPath -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
if (Test-NodeJs) {
|
if (Test-NodeJs) {
|
||||||
Write-Step "Node.js erfolgreich installiert!"
|
Write-Step "Node.js erfolgreich installiert!"
|
||||||
} else {
|
} else {
|
||||||
Write-Err "Node.js wurde installiert, ist aber nicht im PATH gefunden."
|
Write-Err "Node.js wurde installiert, ist aber nicht im PATH gefunden."
|
||||||
Write-Host " Bitte das Setup nach einem Neustart erneut ausführen." -ForegroundColor Yellow
|
Write-Host " Bitte das Setup nach einem Neustart erneut ausfuehren." -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,9 +171,14 @@ if (-not (Test-NodeJs)) {
|
||||||
# Benutzereingaben
|
# Benutzereingaben
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
Write-Header "Starface-Verbindung (nur für Zertifikat-Import)"
|
Write-Header "Starface-Verbindung"
|
||||||
Write-Host " Login-Daten werden hier nicht benötigt." -ForegroundColor Gray
|
Write-Host " Das Add-in kommuniziert per HTTPS mit der Starface." -ForegroundColor Gray
|
||||||
Write-Host " Diese konfigurieren Sie später im Add-in in den Sync-Profilen." -ForegroundColor Gray
|
Write-Host " Da die Starface meist ein selbstsigniertes Zertifikat verwendet," -ForegroundColor Gray
|
||||||
|
Write-Host " muss dieses Zertifikat (CA) einmalig als vertrauenswuerdig" -ForegroundColor Gray
|
||||||
|
Write-Host " importiert werden. Dafuer wird hier nur die Adresse benoetigt." -ForegroundColor Gray
|
||||||
|
Write-Host "" -ForegroundColor Gray
|
||||||
|
Write-Host " Login-Daten werden hier NICHT benoetigt - diese konfigurieren" -ForegroundColor Gray
|
||||||
|
Write-Host " Sie spaeter im Add-in in den Sync-Profilen." -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
$starfaceHost = Read-Host "Starface Host/IP-Adresse (z.B. 192.168.1.100 oder pbx.firma.local)"
|
$starfaceHost = Read-Host "Starface Host/IP-Adresse (z.B. 192.168.1.100 oder pbx.firma.local)"
|
||||||
|
|
@ -187,12 +193,12 @@ $starfacePort = if ([string]::IsNullOrWhiteSpace($starfacePortInput)) { 443 } el
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Header "Lokaler Webserver"
|
Write-Header "Lokaler Webserver"
|
||||||
|
|
||||||
$localPortInput = Read-Host "Lokaler HTTPS-Port für das Add-in [444]"
|
$localPortInput = Read-Host "Lokaler HTTPS-Port fuer das Add-in [444]"
|
||||||
$localPort = if ([string]::IsNullOrWhiteSpace($localPortInput)) { 444 } else { [int]$localPortInput }
|
$localPort = if ([string]::IsNullOrWhiteSpace($localPortInput)) { 444 } else { [int]$localPortInput }
|
||||||
|
|
||||||
if (-not (Test-PortAvailable $localPort)) {
|
if (-not (Test-PortAvailable $localPort)) {
|
||||||
Write-Warn "Port $localPort ist bereits belegt!"
|
Write-Warn "Port $localPort ist bereits belegt!"
|
||||||
$localPortInput = Read-Host "Bitte einen anderen Port wählen"
|
$localPortInput = Read-Host "Bitte einen anderen Port waehlen"
|
||||||
$localPort = [int]$localPortInput
|
$localPort = [int]$localPortInput
|
||||||
if (-not (Test-PortAvailable $localPort)) {
|
if (-not (Test-PortAvailable $localPort)) {
|
||||||
Write-Err "Port $localPort ist ebenfalls belegt. Abbruch."
|
Write-Err "Port $localPort ist ebenfalls belegt. Abbruch."
|
||||||
|
|
@ -211,11 +217,11 @@ try {
|
||||||
Import-StarfaceCert $starfaceHost $starfacePort
|
Import-StarfaceCert $starfaceHost $starfacePort
|
||||||
} catch {
|
} catch {
|
||||||
Write-Err "Fehler beim Abrufen des Starface-Zertifikats: $_"
|
Write-Err "Fehler beim Abrufen des Starface-Zertifikats: $_"
|
||||||
Write-Warn "Die Verbindung zur Starface API könnte fehlschlagen."
|
Write-Warn "Die Verbindung zur Starface API koennte fehlschlagen."
|
||||||
Write-Warn "Sie können das Zertifikat später nachholen mit:"
|
Write-Warn "Sie koennen das Zertifikat spaeter nachholen mit:"
|
||||||
Write-Host " .\import-cert.ps1 -Host $starfaceHost -Port $starfacePort" -ForegroundColor White
|
Write-Host " .\import-cert.ps1 -StarfaceHost $starfaceHost -Port $starfacePort" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Möchten Sie trotzdem fortfahren? (j/n)" -ForegroundColor Yellow
|
Write-Host " Moechten Sie trotzdem fortfahren? (j/n)" -ForegroundColor Yellow
|
||||||
$continue = Read-Host
|
$continue = Read-Host
|
||||||
if ($continue -ne "j") { exit 1 }
|
if ($continue -ne "j") { exit 1 }
|
||||||
}
|
}
|
||||||
|
|
@ -255,7 +261,7 @@ $rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store(
|
||||||
$rootStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
$rootStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
||||||
$rootStore.Add($caCert)
|
$rootStore.Add($caCert)
|
||||||
$rootStore.Close()
|
$rootStore.Close()
|
||||||
Write-Step "Lokale CA als vertrauenswürdig importiert."
|
Write-Step "Lokale CA als vertrauenswuerdig importiert."
|
||||||
|
|
||||||
# Localhost-Zertifikat erstellen, signiert von der lokalen CA
|
# Localhost-Zertifikat erstellen, signiert von der lokalen CA
|
||||||
Write-Step "Erstelle localhost-Zertifikat ..."
|
Write-Step "Erstelle localhost-Zertifikat ..."
|
||||||
|
|
@ -276,8 +282,8 @@ $localhostParams = @{
|
||||||
$localhostCert = New-SelfSignedCertificate @localhostParams
|
$localhostCert = New-SelfSignedCertificate @localhostParams
|
||||||
Write-Step "Localhost-Zertifikat erstellt: $($localhostCert.Thumbprint)"
|
Write-Step "Localhost-Zertifikat erstellt: $($localhostCert.Thumbprint)"
|
||||||
|
|
||||||
# Zertifikat und Key als PEM exportieren (für Node.js)
|
# Zertifikat und Key als PEM exportieren (fuer Node.js)
|
||||||
Write-Step "Exportiere Zertifikate für den Webserver ..."
|
Write-Step "Exportiere Zertifikate fuer den Webserver ..."
|
||||||
|
|
||||||
# Zertifikat als PEM
|
# Zertifikat als PEM
|
||||||
$certPem = "-----BEGIN CERTIFICATE-----`n"
|
$certPem = "-----BEGIN CERTIFICATE-----`n"
|
||||||
|
|
@ -286,20 +292,26 @@ $certPem += "`n-----END CERTIFICATE-----"
|
||||||
Set-Content -Path (Join-Path $certDir "localhost.crt") -Value $certPem -Encoding ASCII
|
Set-Content -Path (Join-Path $certDir "localhost.crt") -Value $certPem -Encoding ASCII
|
||||||
|
|
||||||
# Private Key als PEM
|
# Private Key als PEM
|
||||||
$keyBytes = $localhostCert.PrivateKey.ExportPkcs8PrivateKey()
|
# .PrivateKey ist bei signierten Zertifikaten oft null, daher GetRSAPrivateKey() verwenden
|
||||||
|
$rsaKey = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::GetRSAPrivateKey($localhostCert)
|
||||||
|
if (-not $rsaKey) {
|
||||||
|
Write-Err "Private Key konnte nicht gelesen werden."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$keyBytes = $rsaKey.ExportPkcs8PrivateKey()
|
||||||
|
|
||||||
$keyPem = "-----BEGIN PRIVATE KEY-----`n"
|
$keyPem = "-----BEGIN PRIVATE KEY-----`n"
|
||||||
$keyPem += [Convert]::ToBase64String($keyBytes, [Base64FormattingOptions]::InsertLineBreaks)
|
$keyPem += [Convert]::ToBase64String($keyBytes, [Base64FormattingOptions]::InsertLineBreaks)
|
||||||
$keyPem += "`n-----END PRIVATE KEY-----"
|
$keyPem += "`n-----END PRIVATE KEY-----"
|
||||||
Set-Content -Path (Join-Path $certDir "localhost.key") -Value $keyPem -Encoding ASCII
|
Set-Content -Path (Join-Path $certDir "localhost.key") -Value $keyPem -Encoding ASCII
|
||||||
|
|
||||||
# CA-Zertifikat exportieren (für Deinstallation)
|
# CA-Zertifikat exportieren (fuer Deinstallation)
|
||||||
$caCertPem = "-----BEGIN CERTIFICATE-----`n"
|
$caCertPem = "-----BEGIN CERTIFICATE-----`n"
|
||||||
$caCertPem += [Convert]::ToBase64String($caCert.RawData, [Base64FormattingOptions]::InsertLineBreaks)
|
$caCertPem += [Convert]::ToBase64String($caCert.RawData, [Base64FormattingOptions]::InsertLineBreaks)
|
||||||
$caCertPem += "`n-----END CERTIFICATE-----"
|
$caCertPem += "`n-----END CERTIFICATE-----"
|
||||||
Set-Content -Path (Join-Path $certDir "local-ca.crt") -Value $caCertPem -Encoding ASCII
|
Set-Content -Path (Join-Path $certDir "local-ca.crt") -Value $caCertPem -Encoding ASCII
|
||||||
|
|
||||||
# Thumbprints speichern (für Deinstallation)
|
# Thumbprints speichern (fuer Deinstallation)
|
||||||
$certInfo = @{
|
$certInfo = @{
|
||||||
caThumbprint = $caCert.Thumbprint
|
caThumbprint = $caCert.Thumbprint
|
||||||
localhostThumbprint = $localhostCert.Thumbprint
|
localhostThumbprint = $localhostCert.Thumbprint
|
||||||
|
|
@ -317,7 +329,7 @@ Write-Header "Schritt 3: Add-in Dateien installieren"
|
||||||
$webrootDir = Join-Path $InstallDir "webroot"
|
$webrootDir = Join-Path $InstallDir "webroot"
|
||||||
New-Item -ItemType Directory -Path $webrootDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $webrootDir -Force | Out-Null
|
||||||
|
|
||||||
# Prüfen ob dist-Ordner existiert (bereits gebaut)
|
# Pruefen ob dist-Ordner existiert (bereits gebaut)
|
||||||
$distDir = Join-Path $scriptDir "..\dist"
|
$distDir = Join-Path $scriptDir "..\dist"
|
||||||
if (-not (Test-Path $distDir)) {
|
if (-not (Test-Path $distDir)) {
|
||||||
Write-Step "Baue Add-in (npm run build) ..."
|
Write-Step "Baue Add-in (npm run build) ..."
|
||||||
|
|
@ -356,7 +368,7 @@ Write-Header "Schritt 4: Lokalen Webserver einrichten"
|
||||||
# Server-Dateien kopieren
|
# Server-Dateien kopieren
|
||||||
Copy-Item -Path (Join-Path $scriptDir "local-server.js") -Destination $InstallDir -Force
|
Copy-Item -Path (Join-Path $scriptDir "local-server.js") -Destination $InstallDir -Force
|
||||||
|
|
||||||
# import-cert.ps1 ins Installationsverzeichnis kopieren (für spätere Nutzung)
|
# import-cert.ps1 ins Installationsverzeichnis kopieren (fuer spaetere Nutzung)
|
||||||
$importCertSrc = Join-Path $scriptDir "import-cert.ps1"
|
$importCertSrc = Join-Path $scriptDir "import-cert.ps1"
|
||||||
if (Test-Path $importCertSrc) {
|
if (Test-Path $importCertSrc) {
|
||||||
Copy-Item -Path $importCertSrc -Destination $InstallDir -Force
|
Copy-Item -Path $importCertSrc -Destination $InstallDir -Force
|
||||||
|
|
@ -389,21 +401,21 @@ $trigger = New-ScheduledTaskTrigger -AtStartup
|
||||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
|
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
|
||||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit ([TimeSpan]::Zero)
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit ([TimeSpan]::Zero)
|
||||||
|
|
||||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "Lokaler HTTPS-Server für Starface Outlook Sync Add-in" | Out-Null
|
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "Lokaler HTTPS-Server fuer Starface Outlook Sync Add-in" | Out-Null
|
||||||
|
|
||||||
# Task sofort starten
|
# Task sofort starten
|
||||||
Start-ScheduledTask -TaskName $taskName
|
Start-ScheduledTask -TaskName $taskName
|
||||||
Start-Sleep -Seconds 2
|
Start-Sleep -Seconds 2
|
||||||
|
|
||||||
# Prüfen ob der Server läuft
|
# Pruefen ob der Server laeuft
|
||||||
try {
|
try {
|
||||||
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
|
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
|
||||||
$response = Invoke-WebRequest -Uri "https://localhost:$localPort/taskpane.html" -UseBasicParsing -TimeoutSec 5
|
$response = Invoke-WebRequest -Uri "https://localhost:$localPort/taskpane.html" -UseBasicParsing -TimeoutSec 5
|
||||||
if ($response.StatusCode -eq 200) {
|
if ($response.StatusCode -eq 200) {
|
||||||
Write-Step "Lokaler Webserver läuft auf https://localhost:$localPort"
|
Write-Step "Lokaler Webserver laeuft auf https://localhost:$localPort"
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warn "Server-Test fehlgeschlagen. Server startet möglicherweise verzögert."
|
Write-Warn "Server-Test fehlgeschlagen. Server startet moeglicherweise verzoegert."
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
@ -427,16 +439,16 @@ if ($rdRole -and $rdRole.Installed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isTerminalServer) {
|
if ($isTerminalServer) {
|
||||||
Write-Step "Terminal Server erkannt - registriere Add-in für alle Benutzer (HKLM)."
|
Write-Step "Terminal Server erkannt - registriere Add-in fuer alle Benutzer (HKLM)."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Outlook Classic: Shared Folder Catalog per Registry konfigurieren
|
# Outlook Classic: Shared Folder Catalog per Registry konfigurieren
|
||||||
# Terminal Server: HKLM (gilt für alle User), sonst HKCU
|
# Terminal Server: HKLM (gilt fuer alle User), sonst HKCU
|
||||||
$outlookVersions = @("16.0", "15.0")
|
$outlookVersions = @("16.0", "15.0")
|
||||||
$registeredClassic = $false
|
$registeredClassic = $false
|
||||||
|
|
||||||
foreach ($ver in $outlookVersions) {
|
foreach ($ver in $outlookVersions) {
|
||||||
# Prüfen ob diese Outlook-Version installiert ist
|
# Pruefen ob diese Outlook-Version installiert ist
|
||||||
$outlookPath = "HKLM:\Software\Microsoft\Office\$ver\Outlook"
|
$outlookPath = "HKLM:\Software\Microsoft\Office\$ver\Outlook"
|
||||||
if (-not (Test-Path $outlookPath)) {
|
if (-not (Test-Path $outlookPath)) {
|
||||||
$outlookPath = "HKLM:\Software\WOW6432Node\Microsoft\Office\$ver\Outlook"
|
$outlookPath = "HKLM:\Software\WOW6432Node\Microsoft\Office\$ver\Outlook"
|
||||||
|
|
@ -447,24 +459,24 @@ foreach ($ver in $outlookVersions) {
|
||||||
|
|
||||||
$catalogId = [guid]::NewGuid().ToString("B")
|
$catalogId = [guid]::NewGuid().ToString("B")
|
||||||
|
|
||||||
# Bei Terminal Server: in HKLM registrieren (gilt für alle User)
|
# Bei Terminal Server: in HKLM registrieren (gilt fuer alle User)
|
||||||
if ($isTerminalServer) {
|
if ($isTerminalServer) {
|
||||||
$outlookRegPath = "HKLM:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs"
|
$outlookRegPath = "HKLM:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs"
|
||||||
$catalogRegPath = Join-Path $outlookRegPath $catalogId
|
$catalogRegPath = Join-Path $outlookRegPath $catalogId
|
||||||
New-Item -Path $catalogRegPath -Force | Out-Null
|
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 "Url" -Value $catalogDir -PropertyType String -Force | Out-Null
|
||||||
New-ItemProperty -Path $catalogRegPath -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null
|
New-ItemProperty -Path $catalogRegPath -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null
|
||||||
Write-Step "Add-in Katalog für alle Benutzer registriert (HKLM)."
|
Write-Step "Add-in Katalog fuer alle Benutzer registriert (HKLM)."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Immer auch in HKCU für den aktuellen User (Fallback / Einzelplatz)
|
# Immer auch in HKCU fuer den aktuellen User (Fallback / Einzelplatz)
|
||||||
$outlookRegPathUser = "HKCU:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs"
|
$outlookRegPathUser = "HKCU:\Software\Microsoft\Office\$ver\WEF\TrustedCatalogs"
|
||||||
$catalogRegPathUser = Join-Path $outlookRegPathUser $catalogId
|
$catalogRegPathUser = Join-Path $outlookRegPathUser $catalogId
|
||||||
New-Item -Path $catalogRegPathUser -Force | Out-Null
|
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 "Url" -Value $catalogDir -PropertyType String -Force | Out-Null
|
||||||
New-ItemProperty -Path $catalogRegPathUser -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null
|
New-ItemProperty -Path $catalogRegPathUser -Name "Flags" -Value 1 -PropertyType DWord -Force | Out-Null
|
||||||
|
|
||||||
Write-Step "Add-in Katalog für Outlook Classic registriert."
|
Write-Step "Add-in Katalog fuer Outlook Classic registriert."
|
||||||
$registeredClassic = $true
|
$registeredClassic = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -473,15 +485,15 @@ if (-not $registeredClassic) {
|
||||||
Write-Warn "Outlook Classic nicht in der Registry gefunden."
|
Write-Warn "Outlook Classic nicht in der Registry gefunden."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prüfen ob New Outlook installiert ist
|
# Pruefen ob New Outlook installiert ist
|
||||||
$newOutlook = Get-AppxPackage -Name "Microsoft.OutlookForWindows" -ErrorAction SilentlyContinue
|
$newOutlook = Get-AppxPackage -Name "Microsoft.OutlookForWindows" -ErrorAction SilentlyContinue
|
||||||
if ($newOutlook) {
|
if ($newOutlook) {
|
||||||
Write-Step "Neues Outlook gefunden: Version $($newOutlook.Version)"
|
Write-Step "Neues Outlook gefunden: Version $($newOutlook.Version)"
|
||||||
Write-Warn "Für das neue Outlook muss das Add-in manuell hinzugefügt werden:"
|
Write-Warn "Fuer das neue Outlook muss das Add-in manuell hinzugefuegt werden:"
|
||||||
Write-Host " 1. Neues Outlook öffnen" -ForegroundColor White
|
Write-Host " 1. Neues Outlook oeffnen" -ForegroundColor White
|
||||||
Write-Host " 2. Einstellungen (Zahnrad) → Add-Ins verwalten" -ForegroundColor White
|
Write-Host " 2. Einstellungen (Zahnrad) -> Add-Ins verwalten" -ForegroundColor White
|
||||||
Write-Host " 3. 'Benutzerdefinierte Add-Ins' → 'Aus Datei hinzufügen'" -ForegroundColor White
|
Write-Host " 3. 'Benutzerdefinierte Add-Ins' -> 'Aus Datei hinzufuegen'" -ForegroundColor White
|
||||||
Write-Host " 4. Datei wählen: $catalogDir\manifest.xml" -ForegroundColor White
|
Write-Host " 4. Datei waehlen: $catalogDir\manifest.xml" -ForegroundColor White
|
||||||
} else {
|
} else {
|
||||||
Write-Step "Neues Outlook nicht installiert (nur Classic erkannt)."
|
Write-Step "Neues Outlook nicht installiert (nur Classic erkannt)."
|
||||||
}
|
}
|
||||||
|
|
@ -515,25 +527,25 @@ Write-Host ""
|
||||||
|
|
||||||
if ($registeredClassic) {
|
if ($registeredClassic) {
|
||||||
Write-Host " Outlook Classic: Add-in wurde automatisch registriert." -ForegroundColor Green
|
Write-Host " Outlook Classic: Add-in wurde automatisch registriert." -ForegroundColor Green
|
||||||
Write-Host " → Outlook neu starten, dann 'Kontakt-Sync' im Ribbon suchen." -ForegroundColor Green
|
Write-Host " Outlook neu starten, dann 'Kontakt-Sync' im Ribbon suchen." -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newOutlook) {
|
if ($newOutlook) {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Neues Outlook: Bitte Add-in manuell hinzufügen (siehe oben)." -ForegroundColor Yellow
|
Write-Host " Neues Outlook: Bitte Add-in manuell hinzufuegen (siehe oben)." -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Nächster Schritt: Im Add-in ein Sync-Profil mit den" -ForegroundColor White
|
Write-Host " Naechster Schritt: Im Add-in ein Sync-Profil mit den" -ForegroundColor White
|
||||||
Write-Host " Starface-Zugangsdaten einrichten." -ForegroundColor White
|
Write-Host " Starface-Zugangsdaten einrichten." -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Weitere Starface-Anlagen einbinden? Zertifikat importieren mit:" -ForegroundColor Gray
|
Write-Host " Weitere Starface-Anlagen einbinden? Zertifikat importieren mit:" -ForegroundColor Gray
|
||||||
Write-Host " .\import-cert.ps1 -StarfaceHost <host> [-Port <port>]" -ForegroundColor Gray
|
Write-Host " .\import-cert.ps1 -StarfaceHost <host> [-Port <port>]" -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Deinstallation: uninstall.ps1 als Administrator ausführen" -ForegroundColor Gray
|
Write-Host " Deinstallation: uninstall.ps1 als Administrator ausfuehren" -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Firewall-Regel für den lokalen Port (nur localhost, rein vorsichtshalber)
|
# Firewall-Regel fuer den lokalen Port (nur localhost, rein vorsichtshalber)
|
||||||
New-NetFirewallRule -DisplayName "Starface Outlook Sync" -Direction Inbound -LocalPort $localPort -Protocol TCP -Action Allow -Profile Private -ErrorAction SilentlyContinue | Out-Null
|
New-NetFirewallRule -DisplayName "Starface Outlook Sync" -Direction Inbound -LocalPort $localPort -Protocol TCP -Action Allow -Profile Private -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
|
||||||
Read-Host "Eingabetaste zum Beenden"
|
Read-Host "Eingabetaste zum Beenden"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Deinstalliert das Starface Outlook Sync Add-in.
|
Deinstalliert das Starface Outlook Sync Add-in.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Entfernt Server, Zertifikate, Scheduled Task, Registry-Einträge und Dateien.
|
Entfernt Server, Zertifikate, Scheduled Task, Registry-Eintraege und Dateien.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param(
|
param(
|
||||||
|
|
@ -21,17 +21,17 @@ function Write-Header($text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Step($text) {
|
function Write-Step($text) {
|
||||||
Write-Host " → $text" -ForegroundColor Green
|
Write-Host " [OK] $text" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Warn($text) {
|
function Write-Warn($text) {
|
||||||
Write-Host " ⚠ $text" -ForegroundColor Yellow
|
Write-Host " [!] $text" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Header "Starface Outlook Sync - Deinstallation"
|
Write-Header "Starface Outlook Sync - Deinstallation"
|
||||||
|
|
||||||
# Sicherheitsabfrage
|
# Sicherheitsabfrage
|
||||||
Write-Host " Dies entfernt das Starface Outlook Sync Add-in vollständig." -ForegroundColor Yellow
|
Write-Host " Dies entfernt das Starface Outlook Sync Add-in vollstaendig." -ForegroundColor Yellow
|
||||||
Write-Host " Installationsverzeichnis: $InstallDir" -ForegroundColor Yellow
|
Write-Host " Installationsverzeichnis: $InstallDir" -ForegroundColor Yellow
|
||||||
$confirm = Read-Host " Fortfahren? (j/n)"
|
$confirm = Read-Host " Fortfahren? (j/n)"
|
||||||
if ($confirm -ne "j") {
|
if ($confirm -ne "j") {
|
||||||
|
|
@ -68,7 +68,7 @@ $certInfoPath = Join-Path $InstallDir "cert-info.json"
|
||||||
if (Test-Path $certInfoPath) {
|
if (Test-Path $certInfoPath) {
|
||||||
$certInfo = Get-Content $certInfoPath -Raw | ConvertFrom-Json
|
$certInfo = Get-Content $certInfoPath -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
# Localhost-Zertifikat aus dem persönlichen Store entfernen
|
# Localhost-Zertifikat aus dem persoenlichen Store entfernen
|
||||||
if ($certInfo.localhostThumbprint) {
|
if ($certInfo.localhostThumbprint) {
|
||||||
$cert = Get-ChildItem "Cert:\LocalMachine\My" | Where-Object { $_.Thumbprint -eq $certInfo.localhostThumbprint }
|
$cert = Get-ChildItem "Cert:\LocalMachine\My" | Where-Object { $_.Thumbprint -eq $certInfo.localhostThumbprint }
|
||||||
if ($cert) {
|
if ($cert) {
|
||||||
|
|
@ -85,14 +85,14 @@ if (Test-Path $certInfoPath) {
|
||||||
Write-Step "Lokale CA entfernt."
|
Write-Step "Lokale CA entfernt."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Auch aus dem persönlichen Store
|
# Auch aus dem persoenlichen Store
|
||||||
$caCertMy = Get-ChildItem "Cert:\LocalMachine\My" | Where-Object { $_.Thumbprint -eq $certInfo.caThumbprint }
|
$caCertMy = Get-ChildItem "Cert:\LocalMachine\My" | Where-Object { $_.Thumbprint -eq $certInfo.caThumbprint }
|
||||||
if ($caCertMy) {
|
if ($caCertMy) {
|
||||||
Remove-Item $caCertMy.PSPath -Force
|
Remove-Item $caCertMy.PSPath -Force
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Warn "cert-info.json nicht gefunden. Zertifikate müssen ggf. manuell entfernt werden."
|
Write-Warn "cert-info.json nicht gefunden. Zertifikate muessen ggf. manuell entfernt werden."
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
@ -161,11 +161,11 @@ Write-Header "Deinstallation abgeschlossen"
|
||||||
Write-Host " Das Starface Outlook Sync Add-in wurde entfernt." -ForegroundColor Green
|
Write-Host " Das Starface Outlook Sync Add-in wurde entfernt." -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Hinweis: Falls das Add-in im neuen Outlook manuell" -ForegroundColor Gray
|
Write-Host " Hinweis: Falls das Add-in im neuen Outlook manuell" -ForegroundColor Gray
|
||||||
Write-Host " hinzugefügt wurde, muss es dort auch manuell entfernt werden:" -ForegroundColor Gray
|
Write-Host " hinzugefuegt wurde, muss es dort auch manuell entfernt werden:" -ForegroundColor Gray
|
||||||
Write-Host " Einstellungen → Add-Ins verwalten → Add-In entfernen" -ForegroundColor Gray
|
Write-Host " Einstellungen -> Add-Ins verwalten -> Add-In entfernen" -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " Das Starface-Zertifikat wurde NICHT entfernt," -ForegroundColor Yellow
|
Write-Host " Das Starface-Zertifikat wurde NICHT entfernt," -ForegroundColor Yellow
|
||||||
Write-Host " da es ggf. von anderen Anwendungen benötigt wird." -ForegroundColor Yellow
|
Write-Host " da es ggf. von anderen Anwendungen benoetigt wird." -ForegroundColor Yellow
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
Read-Host "Eingabetaste zum Beenden"
|
Read-Host "Eingabetaste zum Beenden"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue