PowerShell
PowerShell copied to clipboard
Make compatible with PS7
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.
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" }