Update vCenter-SSL.ps1

This commit is contained in:
2025-08-26 18:15:19 -05:00
parent 62ea634793
commit 41b2131f16

View File

@@ -80,36 +80,36 @@ Else {
New-PAAccount -Contact $EmailContact -AcceptTOS -Force -Confirm:$false New-PAAccount -Contact $EmailContact -AcceptTOS -Force -Confirm:$false
} }
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type) { # if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type) {
$certCallback = @" # $certCallback = @"
using System; # using System;
using System.Net; # using System.Net;
using System.Net.Security; # using System.Net.Security;
using System.Security.Cryptography.X509Certificates; # using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback # public class ServerCertificateValidationCallback
{ # {
public static void Ignore() # public static void Ignore()
{ # {
if(ServicePointManager.ServerCertificateValidationCallback ==null) # if(ServicePointManager.ServerCertificateValidationCallback ==null)
{ # {
ServicePointManager.ServerCertificateValidationCallback += # ServicePointManager.ServerCertificateValidationCallback +=
delegate # delegate
( # (
Object obj, # Object obj,
X509Certificate certificate, # X509Certificate certificate,
X509Chain chain, # X509Chain chain,
SslPolicyErrors errors # SslPolicyErrors errors
) # )
{ # {
return true; # return true;
}; # };
} # }
} # }
} # }
"@ # "@
Add-Type $certCallback # Add-Type $certCallback
} # }
[ServerCertificateValidationCallback]::Ignore() # [ServerCertificateValidationCallback]::Ignore()
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Credential.UserName + ':' + $Credential.GetNetworkCredential().Password)) $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Credential.UserName + ':' + $Credential.GetNetworkCredential().Password))
$head = @{ $head = @{