EvotecIT / PSPGP

PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
MIT License
59 stars 22 forks source link

Protect-PGP exception when running in PowerShell 5.1 in Azure Automations Runbook #10

Closed mknight2241 closed 1 month ago

mknight2241 commented 2 years ago

Hey Team,

I'm trying to use use Protect-PGP in an Azure Automations Runbook. The cmdlet runs great using the 7.1 preview Runbooks but returns the following exception on 5.1: Protect-PGP - Can't encrypt string: Exception calling "EncryptArmoredString" with "1" argument(s): "Premature end of stream in PartialInputStream"

The docs for the Runbooks state that the sandbox where the scripts run have .NET Framework 4.7.2, so it should meet the requirements of the Module https://docs.microsoft.com/en-us/azure/automation/automation-runbook-execution#runbook-execution-environment

The code that I'm using is very simple for testing: Protect-PGP -FilePathPublic $KeyPath -String "This needs to be protected"

I've also attempted to test with in input file and it returned a very similar error: Protect-PGP - Can't encrypt file C:\Users\Client\Temp\ToProtect.txt: Exception calling "EncryptFile" with "2" argument(s): "Premature end of stream in PartialInputStream"

PrzemyslawKlys commented 1 year ago

can you try new version?