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

Access to the path is denied #22

Closed keteague closed 2 weeks ago

keteague commented 3 weeks ago

PowerShell 5.1

When I attempt to use the -OutFilePath parameter, whether I'm using Protect-PGP or Unprotect-PGP, I'm getting an Access to the path is denied error.

If I call Protect-PGP without the -OutFilePath parameter, it'll place the encrypted files in the same directory as the source files. I do not have that option when attempting to run Unprotect-PGP. It seems to require the -OutFilePath parameter to be defined.

This is not a permission issue as I can write to the directory without problems.


...
Decrypting testFile8.csv.pgp...
WARNING: Unprotect-PGP - Remove PGP encryption from D:\Sage\Concur\Import\Processing\testFile8.csv.pgp failed: Exception calling "DecryptFile" with "4" argument(s): "Acce
ss to the path 'D:\Sage\Concur\Import\Processing' is denied."
Decrypting testFile9.csv.pgp...
WARNING: Unprotect-PGP - Remove PGP encryption from D:\Sage\Concur\Import\Processing\testFile9.csv.pgp failed: Exception calling "DecryptFile" with "4" argument(s): "Acce
ss to the path 'D:\Sage\Concur\Import\Processing' is denied."

PS C:\Users\sage100> Unprotect-PGP -FilePathPrivate $pgpPrivateKeyFile -Password $pgpPassword -FilePath "D:\Sage\Concur\Import\testFile1.csv.pgp"
cmdlet Unprotect-PGP at command pipeline position 1
Supply values for the following parameters:
OutFilePath: .
WARNING: Unprotect-PGP - Remove PGP encryption from D:\Sage\Concur\Import\testFile1.csv.pgp failed: Exception calling "DecryptFile" with "4" argument(s): "Access to the p
ath 'C:\Users\sage100' is denied."

PS C:\Users\sage100> Unprotect-PGP -FilePathPrivate $pgpPrivateKeyFile -Password $pgpPassword -FilePath "D:\Sage\Concur\Import\testFile1.csv.pgp" -OutFilePath C:\Temp
WARNING: Unprotect-PGP - Remove PGP encryption from D:\Sage\Concur\Import\testFile1.csv.pgp failed: Exception calling "DecryptFile" with "4" argument(s): "Access to the p
ath 'C:\Temp' is denied."

PS C:\Users\sage100> New-Item "D:\Sage\Concur\Import\Processing\testfoo.txt"

    Directory: D:\Sage\Concur\Import\Processing

Mode                LastWriteTime         Length Name                                                                                                                    
----                -------------         ------ ----                                                                                                                    
-a----        8/27/2024   4:54 PM              0 testfoo.txt                                                                                                             
PrzemyslawKlys commented 3 weeks ago

The outputfilepath requires full path to file, and not just a folder... if you want to use folder you should use OutputFolderPath.

In other words you tell it the path exactly as required where it's supposed to be saved and under which name.

keteague commented 2 weeks ago

This works. Thank you!