如下说明是翻译: help Read-Host 产生的帮助信息.
译者: Edengundam(马涛)
Read-Host
大纲
从控制台读取一行输入.
语法
Read-Host [[-prompt] <Object>] [-asSecureString] [<CommonParameters>]
详细描述
从控制台读取一行输入. 可以向输入的用户进行提示. 也可以用来创建安全字符串.
参数
-prompt <Object>
提供将会被当作提示信息的对象. 如果提示字符串中包含空格, 必须使用引号将其引起来.
强制参数?
|
false
|
参数位置?
|
1
|
默认值
|
|
允许从管道绑定输入?
|
false
|
允许通配符扩展?
|
false
|
-asSecureString <SwitchParameter>
如果设置为$true, 输入的字符将会以(*)形式回显在屏幕上. 命令的输出对象的类型为Securestring.
强制参数?
|
false
|
参数位置?
|
named
|
默认值
|
False
|
允许从管道绑定输入?
|
false
|
允许通配符扩展?
|
false
|
<公共参数>
此命令支持公共参数: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. 更多信息, 输入, "get-help about_commonparameters".
返回类型
String或SecureString
注意
更多信息, 输入"Get-Help Read-Host -detailed".需要技术信息, 输入"Get-Help Read-Host -full".
如果需要为该命令提供多个参数, 请使用逗号进行分隔. 例如, "<parameter-name> <value1>, <value2>".
例1
C:/PS>$age = read-host "Please enter your age:"
此命令使用"Please enter your age:"作为提示信息. 当输入了一个值并按下回车键(Enter), 该值将会被保存在$age变量中.
例2
C:/PS>$a = read-host "Enter the machine name here"
例3
C:/PS>$pwd_secure_string = read-host "Enter a Password:" -assecurestring
此命令使用"Enter a Password:" 作为提示信息. 当输入信息时, 每次按键都会导致屏幕上显示一个星号(*). 当按下回车键(Enter)后, 该值将以SecureString类型的对象保存于$pwd_secure_string变量中.
相关链接
Get-Host
Out-Host
Write-Host
ConvertFrom-SecureString