diff --git a/inc/vCenter-SSL.ps1 b/inc/vCenter-SSL.ps1 index 74dc2256..d0a78415 100644 --- a/inc/vCenter-SSL.ps1 +++ b/inc/vCenter-SSL.ps1 @@ -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