小编Mat*_*008的帖子

有没有办法在Powershell中预先填写Read-Host?

我有一个脚本可以帮助用户查找文件夹中是否存在文件哈希。用户输入哈希值后,我确定它是什么类型的哈希值,如果不支持它或者用户错过了一个字母,它将返回要求哈希值。为了便于使用,我希望能够预先填写用户之前输入的内容,这样他们就不需要重新开始。

\n\n
while (1)\n{\n    $hashToFind = Read-Host -Prompt "Enter hash to find or type \'file\' for multiple hashes"\n    # Check if user wants to use text file\n    if ($hashToFind -eq "file" )\n    {\n\n        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\n        Start-Sleep -Seconds 3\n        $hashPath = New-Object system.windows.forms.openfiledialog\n        $hashPath.InitialDirectory = \xe2\x80\x9cc:\\\xe2\x80\x9d\n        $hashPath.MultiSelect = $false\n        if($hashPath.showdialog() -ne "OK")\n        {\n            echo "No file was selected. …
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
2884
查看次数

标签 统计

powershell ×1