I am trying to decrpyt the automated pgp message with powershell however it drops an error message: The full error message is: gpg: can’t open `MyEncryptedFile.pgp’: No such file or directory
gpg: decrypt_message failed: No such file or directory
The bottleneck of this task is that I cannot install anything (such as GnuPG)
The sign and encryption part was done with command line commands:
<span class="pln">$path </span><span class="pun">=</span> <span class="str">"\\networkdrive\folder1\message"</span><span class="pln">
$step2files </span><span class="pun">=</span> <span class="typ">Get</span><span class="pun">-</span><span class="typ">ChildItem</span> <span class="pun">-</span><span class="typ">Recurse</span> <span class="pun">-</span><span class="typ">Path</span><span class="pln"> $path </span><span class="pun">|</span> <span class="typ">Where</span><span class="pun">-</span><span class="typ">Object</span><span class="pun">{</span><span class="pln">$_</span><span class="pun">.</span><span class="typ">Extension</span> <span class="pun">-</span><span class="pln">eq </span><span class="str">".asc"</span><span class="pun">}</span><span class="pln">
$z</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
foreach </span><span class="pun">(</span><span class="pln">$files </span><span class="kwd">in</span><span class="pln"> $step2files</span><span class="pun">)</span> <span class="pun">{</span><span class="pln">
$outputname </span><span class="pun">=</span> <span class="str">"$files.pgp"</span><span class="pln">
$input </span><span class="pun">=</span><span class="pln"> $files
$z
$options </span><span class="pun">=</span> <span class="str">" --output $outputname –-encrypt --recipient XYKey $files"</span><span class="pln">
$options
gpg </span><span class="pun">--</span><span class="pln">output $outputname </span><span class="pun">--</span><span class="pln">encrypt </span><span class="pun">--</span><span class="pln">recipient </span><span class="typ">XYKey</span><span class="pln"> $input
$z</span><span class="pun">++</span>
<span class="pun">}</span>
I need the response decrypted in a similar way and even though powershell finds all the respective files, the aforementioned error message displays.
The codepart is:
<span class="pln">$extracted </span><span class="pun">=</span> <span class="str">"\\networkdrive\folder1\extracted"</span><span class="pln">
$step5files </span><span class="pun">=</span> <span class="typ">Get</span><span class="pun">-</span><span class="typ">ChildItem</span> <span class="pun">-</span><span class="typ">Recurse</span> <span class="pun">-</span><span class="typ">Path</span><span class="pln"> $extracted </span><span class="pun">|</span> <span class="typ">Where</span><span class="pun">-</span><span class="typ">Object</span><span class="pun">{</span><span class="pln">$_</span><span class="pun">.</span><span class="typ">Extension</span> <span class="pun">-</span><span class="pln">eq </span><span class="str">".pgp"</span><span class="pun">}</span><span class="pln">
$z</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
foreach </span><span class="pun">(</span><span class="pln">$files </span><span class="kwd">in</span><span class="pln"> $step5files</span><span class="pun">)</span> <span class="pun">{</span><span class="pln">
$outputname </span><span class="pun">=</span> <span class="str">"$files.xml"</span><span class="pln">
$input </span><span class="pun">=</span><span class="pln"> $files
$z
$options </span><span class="pun">=</span> <span class="str">" -u KeyID --batch --yes --passphrase password --output $outputname --decrypt $files"</span><span class="pln">
$options
gpg </span><span class="pun">-</span><span class="pln">u </span><span class="typ">KeyID</span> <span class="pun">--</span><span class="pln">batch </span><span class="pun">--</span><span class="pln">yes </span><span class="pun">--</span><span class="pln">passphrase password </span><span class="pun">--</span><span class="pln">output $outputname </span><span class="pun">--</span><span class="pln">decrypt $input
$z</span><span class="pun">++</span>
<span class="pun">}</span>
Any idea?