dell / powershell-vxrail

powershell-vxrail
0 stars 2 forks source link

VxRail.API.Common using deprecated function CertificatePolicy which doesnt work in Powershell 7 #2

Open frznto opened 8 months ago

frznto commented 8 months ago

The VxRail.API.Common is using the deprecated "[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy" found on line 20, and no longer works when trying to use Powershell 7, either administrator or normal user. The module will import in Powershell 5.1

Reference: https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.certificatepolicy?view=netframework-4.7.2

PowerShell 7.4.1 PS C:\Windows\System32> Import-Module VxRail.API Import-Module: (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a using directive or an assembly reference?) public class TrustAllCertsPolicy : ICertificatePolicy { ^ PS C:\Windows\System32> Import-Module VxRail.API.Certificate Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a | using directive or an assembly reference?) public class TrustAllCertsPolicy : ICertificatePolicy { | ^ Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | Cannot add type. Compilation errors occurred. New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20 Line | 20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | ~~~~~~ | Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded. PS C:\Windows\System32> Import-Module VxRail.API.Chassis PS C:\Windows\System32> Import-Module VxRail.API.Cluster Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a | using directive or an assembly reference?) public class TrustAllCertsPolicy : ICertificatePolicy { | ^ Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | Cannot add type. Compilation errors occurred. New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20 Line | 20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | ~~~~~~ | Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded. PS C:\Windows\System32> Import-Module VxRail.API.disk Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a using directive or an assembly reference?) public class | TrustAllCertsPolicy : ICertificatePolicy { ^ Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9 Line | 9 | add-type @" | ~~~ | Cannot add type. Compilation errors occurred. New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20 Line | 20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | ~~~~~~ | Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded. PS C:\Windows\System32>