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
57 stars 21 forks source link

Unprotect-PGP does not resolve path #3

Closed Szeraax closed 2 years ago

Szeraax commented 3 years ago

When I run the parameters -FilePath or -OutputFilePath with home dir shortcut, I get the following errors:

Could not find a part of the path 'H:\~\Downloads\testoutput.zip'.
Encrypted File [~\Downloads\test.pgp] not found.

Not using resolve-path probably applies to other param sets, haven't tried them. Feel free to close as WONTFIX and comment here that relative paths can't use aliases or need to be absolute paths. Or I can submit a PR in a little bit.

Additionally, these fatal errors do not result in red test and error, so the only way to test if the command succeeded is to do a test-path on the expected output path. Would recommend a throw anytime decryption is stopped or at least a -Passthru param that will ONLY produce pipeline output on successful decryption.

PrzemyslawKlys commented 3 years ago

I would be more than happy to accept your PR. Probably all my projects suffer from similar problems.

As for testing, you can always do Unprotect-PGP -ErrorAction Stop and the warnings are changed into the throw. It's a decision i did some time ago that by default you go by warnings, and if you want to have control over the process yourself you use ErrorAction Stop.