我有一段时间没有使用过PowerShell,但仍然知道基础知识。我正在尝试创建一个脚本,通过检查主机名IP地址输出csv文件。如果IP地址对于主机名是正确的,则输出YES。如果主机名的IP错误,则输出NO。我在这里搜索过,也在其他网站上搜索过。这就是我所拥有的。任何帮助将不胜感激。谢谢你们的社区! :
$names = Get-content "hnames.txt"
foreach ($name in $names){
if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
Write-Host "$name,up"
}
else{+
Write-Host "$name,down"
}
}
答案 0 :(得分:2)
我做这样的事情:
{
"CreationDate": "2018-4-3",
"Commands": [
{
"Command": "open",
"Target": "https://ocr.space/",
"Value": ""
},
{
"Command": "label",
"Target": "u1",
"Value": ""
},
{
"Command": "storeValue",
"Target": "id=imageFile",
"Value": "mypath"
},
{
"Command": "echo",
"Target": "mypath=${mypath}",
"Value": "blue"
},
{
"Command": "gotoIf",
"Target": "x=\"${mypath}\"; (x.length < 2);",
"Value": "u1"
},
{
"Command": "click",
"Target": "link=Start OCR!",
"Value": ""
}
]
}