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