【发布时间】:2018-03-14 06:52:39
【问题描述】:
我被困在这个: 用户需要输入两个计算机名称,我不知道如何将它们转换为一个输入(也许我问错了),但这里是代码
elseif ($usersinput -eq 2)
{
$pingingtwopcs = Read-Host -Prompt "what are the names of the pc that >you want to ping? (please enter pc names in the next order with comma : >pc1,pc2)"
foreach ($pcs in $pingingtwopcs)
{
Test-Connection -computername $pcs -Count 1
}
}
请不要提供解决方案,如果可以请指导我,我会自己解决。
【问题讨论】:
-
Read-Host将返回一个字符串,而不是两个变量。所以你必须split那个字符串
标签: powershell variables user-input