PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Make compatible with PS7

Open muravsky opened this issue 1 year ago • 1 comments

I've found out, that current code is not compatible with PS7 slightly.

Changing $certbytes | Set-Content -Encoding Byte -Path $pfxPath -ea Stop to $certbytes | Set-Content -AsByteStream -Path $pfxPath -ea Stop

Fixed the issue for me. Please consider changing it in repository.

muravsky avatar May 22 '23 13:05 muravsky

Thank you for your input! With your advice, I'm now able to utilize it in PS7. Nonetheless, I've discovered that the following if-condition is particularly beneficial for individuals who are still operating in PS5.

if ($PSVersionTable.PSVersion.Major -eq 7) { $certbytes | Set-Content -AsByteStream -Path $pfxPath -ea Stop } elseif ($PSVersionTable.PSVersion.Major -eq 5) { $certbytes | Set-Content -Encoding Byte -Path $pfxPath -ea Stop } else { Write-Host "No Supported PS Version" }

Kryptox95 avatar May 02 '24 07:05 Kryptox95