Update vCenter-SSL.ps1

This commit is contained in:
2025-11-15 19:00:54 -06:00
parent 8daa91ff71
commit dac1bdcc4b

View File

@@ -1,10 +1,6 @@
#!/usr/bin/env pwsh
# -----------------------------------------------------------------------------------
# vCenter + Posh-ACME Script (Linux/macOS-safe)
# - Uses -SkipCertificateCheck to bypass SSL validation
# - Proper ErrorRecord handling
# - PowerDNS plugin uses plain string API key
# - Fault-tolerant ACME certificate handling
# vCenter + Posh-ACME Script (Linux/macOS-safe, fixed HTTP content read)
# -----------------------------------------------------------------------------------
. /opt/idssys/nodemgmt/conf/powerwall/settings.ps1
@@ -109,14 +105,15 @@ if (-not (Get-Module -ListAvailable -Name Posh-ACME)) {
Import-Module Posh-ACME -ErrorAction Stop
# ----------------------------
# Connect to vCenter API
# Connect to vCenter API using Invoke-WebRequest
# ----------------------------
$loginUri = "https://$vCenterURL/rest/com/vmware/cis/session"
Write-Host "Connecting to vCenter at $vCenterURL ..." -ForegroundColor Cyan
try {
$sessionResponse = Invoke-SafeRestMethod -Uri $loginUri -Method Post -Headers @{}
$sessionToken = $sessionResponse.value
$resp = Invoke-WebRequest -Uri $loginUri -Method Post -SkipCertificateCheck -UseBasicParsing -Headers @{}
$json = $resp.Content | ConvertFrom-Json
$sessionToken = $json.value
if (-not $sessionToken) {
throw [System.Exception] "Unable to obtain vCenter session token"
}
@@ -136,7 +133,7 @@ try {
} catch { Write-Host "Unable to retrieve VM list, continuing..." -ForegroundColor Yellow }
# ----------------------------
# Fault-tolerant ACME certificate request
# ACME certificate request
# ----------------------------
$certName = "vcenter-cert"
$certSuccess = $false