Update vCenter-SSL.ps1

This commit is contained in:
2025-11-15 19:58:35 -06:00
parent c478f4d8b5
commit 22472383be

View File

@@ -73,16 +73,16 @@ Import-Module Posh-ACME -ErrorAction Stop
# ---------------------------- # ----------------------------
# ACME / PowerDNS certificate request # ACME / PowerDNS certificate request
# ---------------------------- # ----------------------------
# Ensure API key is plain string (Posh-ACME PowerDNS plugin requires string) # Convert API key to SecureString for PowerDNS plugin
if ($PDNSAPI -is [System.Security.SecureString]) { if ($PDNSAPI -is [string]) {
$PDNSAPI = [Runtime.InteropServices.Marshal]::PtrToStringAuto( $securePDNSAPI = ConvertTo-SecureString $PDNSAPI -AsPlainText -Force
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($PDNSAPI) } else {
) $securePDNSAPI = $PDNSAPI
} }
$pArgs = @{ $pArgs = @{
PowerDNSApiHost = $WDNSHOST PowerDNSApiHost = $WDNSHOST
PowerDNSApiKey = $PDNSAPI PowerDNSApiKey = $securePDNSAPI
PowerDNSUseTLS = $true PowerDNSUseTLS = $true
PowerDNSPort = 443 PowerDNSPort = 443
PowerDNSServerName = 'localhost' PowerDNSServerName = 'localhost'
@@ -148,16 +148,13 @@ if ($certSuccess) {
} }
# ---------------------------- # ----------------------------
# Restart vpxd service via REST (safe for vCenter appliance) # vpxd restart note
# ---------------------------- # ----------------------------
try { Write-Host ""
Write-Host "Restarting vpxd service via REST..." -ForegroundColor Yellow Write-Host "IMPORTANT:" -ForegroundColor Yellow
$uriRestart = "https://$VCENTERHOST/rest/appliance/system/services/vpxd?action=restart" Write-Host "Automatic vpxd restart skipped because REST endpoint is not available." -ForegroundColor Yellow
Invoke-RestMethod -Uri $uriRestart -Method Post -Headers $sessionHeaders -SkipCertificateCheck Write-Host "Please restart the vCenter vpxd service manually via SSH:" -ForegroundColor Yellow
Write-Host "vpxd service restart requested." -ForegroundColor Yellow Write-Host "ssh root@$VCENTERHOST 'service-control --stop vpxd; service-control --start vpxd'" -ForegroundColor Yellow
} catch {
Write-Host "Failed to restart vpxd service: $($_.Exception.Message)" -ForegroundColor Yellow
$global:helpme = $_.Exception.Message
}
Write-Host ""
Write-Host "Script completed. Check `$global:helpme for any error details." -ForegroundColor Green Write-Host "Script completed. Check `$global:helpme for any error details." -ForegroundColor Green