【发布时间】:2017-02-11 10:02:35
【问题描述】:
我有一个脚本,它要求用户输入,然后将其用作变量来验证目录路径是否存在,但是当用户输入 * 时,验证会在它应该失败的地方返回成功。
输入是通过Read-Host完成的,代码示例如下。
$userinput = Read-Host -Prompt "Enter Value"
if(Test-Path -Path "c:\$userinput\") {"Valid"} else {"not valid"}
【问题讨论】:
-
-Path->-LiteralPath -
谢谢,这么简单你已经提到了