我正在尝试创建一个脚本来检查zip文件的密码。密码存储在文本文件中。脚本运行正常,但我想在密码匹配的地方停止脚本,或者我可以导出csv文件吗?有人能帮我吗
$passfile = Get-Content "C:\Users\parveen.kumar\Downloads\passwords.txt"
$7ZipexePath = "C:\Program Files\7-Zip\7z.exe"
$zipFile = "C:\users\parveen.kumar\Downloads\just.zip"
foreach ($password in $passwords)
{
Write-Host $password
& $7ZipexePath "t" $zipFile "-p$passfile"
if (-Not $?)
{
Write-Host $password "This is incorrect password."
} else {
Write-Host $password "This is the correct password." -ForegroundColor Red
}
}
1条答案
按热度按时间zf9nrax11#