好吧,我一直被困在创建的PowerShell脚本中,该脚本使用PGP加密自动加密/解密文件。我测试了每行代码都可以运行,但是不能单独运行,所以我试图查看如何将gpg输出到日志文件,以期确定问题所在。
我尝试了--log-file,-logger-fd,但是什么也没有...
$DestPath = "\\some UNC path"
$files = Get-ChildItem $DestPath -File
ForEach($file in $files)
{
try
{
$outfile = $file.BaseName
Write-Output "PGP Procesing: Input=$DestPath\$file, Output=$DestPath\$outfile"
Start-Process -wait -FilePath "C:\Program Files (x86)\GnuPG\bin\gpg.exe" -WorkingDirectory "$DestPath" -ArgumentList "--pinentry-mode=loopback --passphrase "some pwd" --logger-fd "C:\Logs\GPG.txt" -o $DestPath\$outfile $DestPath\$file"
}
catch
{
Write-Output "Error during PGP decryption of: $file"
}
}
任何帮助将不胜感激!