yoke88 / PSPHPIPAM

MIT License
21 stars 18 forks source link

Additional check in Disable-CertsCheck.ps1 ('TrustAllCertsPolicy' already exists) #20

Closed YuriB9 closed 3 years ago

YuriB9 commented 3 years ago

Hello,

My script already disables cert check at the beginning in the same way. Later, in the middle of the script, I try to import the PSPHPIPAM module and receive the error below:

add-type : Cannot add type. The type name 'TrustAllCertsPolicy' already exists.
At C:\Program 
Files\WindowsPowerShell\Modules\PSPHPIPAM\1.3.2\Functions\Private\Disable-CertsCheck.ps1:14 char:9

Is it possible to add one additional check for this type? Something like this:

if (-not ("TrustAllCertsPolicy" -as [type])) {
        Add-Type ...
        [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
}
yoke88 commented 3 years ago

fixed in da894dc