如何格式化以下name,address,url
adam,hills 32,http://rockit.com
jane,valleys 23,http://popit.com
命令的输出文件?我需要在失败的机器上重做
{
"name": "adam",
"address": "hills 32",
"url": "http://rockit.com"
}
答案 0 :(得分:1)
在PowerShell中?你可以在这样的变量中收集它:
$output = & wmic '/node:@D:\input.txt' nicconfig where '(IPEnabled=TRUE and DHCPEnabled=FALSE)' call SetDNSServerSearchOrder '("9.1.1.1","10.1.1.1")'
如果 您首先正在运行wmic
。你不是。
在PowerShell中,使用适当的cmdlet进行WMI操作(例如Get-WmiObject
):
$dnsServers = '9.1.1.1', '10.1.1.1'
$computers = Get-Content 'D:\input.txt'
$output = Get-WmiObject -Computer $computers -Class Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=True AND DHCPEnabled=False' |
ForEach-Object { $_.SetDNSServerSearchOrder($dnsServers) }