2
폴더에 파일 해시가 있는지 찾는 데 도움이되는 스크립트가 있습니다. 사용자가 해시를 입력 한 후 어떤 유형의 해시인지 확인하고 지원되지 않거나 사용자가 편지를 놓친 경우 해시를 요청하는 것으로 돌아갑니다. 사용 편의성을 위해 사용자가 이전에 입력 한 내용을 미리 채울 수 있기를 원하므로 처음부터 다시 시작할 필요가 없습니다.Powershell에서 Read-Host를 미리 채울 수 있습니까?
while (1)
{
$hashToFind = Read-Host -Prompt "Enter hash to find or type 'file' for multiple hashes"
# Check if user wants to use text file
if ($hashToFind -eq "file")
{
Write-Host "Be aware program will only support one has type at a time. Type is determined by the first hash in the file." -ForegroundColor Yellow
Start-Sleep -Seconds 3
$hashPath = New-Object system.windows.forms.openfiledialog
$hashPath.InitialDirectory = “c:\”
$hashPath.MultiSelect = $false
if($hashPath.showdialog() -ne "OK")
{
echo "No file was selected. Exiting program."
Return
}
$hashToFind = Get-Content $hashPath.filename
}
# Changes string to array
if ($hashToFind.GetTypeCode() -eq "String")
{
$hashToFind+= " a"
$hashToFind = $hashToFind.Split(" ")
}
if ($hashToFind[0].Length -eq 40){$hashType = "SHA1"; break}
elseif ($hashToFind[0].Length -eq 64){$hashType = "SHA256"; break}
elseif ($hashToFind[0].Length -eq 96){$hashType = "SHA384"; break}
elseif ($hashToFind[0].Length -eq 128){$hashType = "SHA512"; break}
elseif ($hashToFind[0].Length -eq 32){$hashType = "MD5"; break}
else {echo "Hash length is not of supported hash type."}
}
저는 PowerShell의 최신 버전입니다. 다른 의견이 있으면 환영합니다!
가 AFAIK 그러나 데이터가 명령 기록에 저장됩니다 프롬프트에 입력 읽기 호스트 대화 상자를 미리 채울 방법이 없다 그래서 모든 사용자가 이전에 입력 한 해시로 돌아가려면 '위로'화살표 키를 누르기 만하면됩니다. 그러면 원하는대로 편집 할 수 있습니다. 그러나 스크립트를 살펴보면 [매개 변수 유효성 검사] (https://blogs.technet.microsoft.com/heyscriptingguy/2011/05/15/simplify-your-powershell-script-with-parameter-validation/)를 사용하는 것이 더 좋습니다.) 대신에 루프 –
을 미리 채울 방법이 없습니다. 제가 아는 한. – 4c74356b41