When testing with self-signed certificates PowerShell cmdlets that connect to SSL/TLS services will refuse to work because they can't verify a self-signed certificate.
To get around that first execute:
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
And then use the desired cmdlet.
Source:Today I learned - Set Powershell to skip SSL certificate checks