User Tools

Site Tools


microsoft:programming:powershell:notes

Microsoft - Programming - PowerShell - Notes

Skip TLS check

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

microsoft/programming/powershell/notes.txt · Last modified: 2022/08/14 16:23 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki