2017-01-10 82 views
-2

如何格式化输出文件以下wmic命令?我需要返修失败的机器在WMIC输出中需要帮助

wmic /node:@D:\input.txt /Output:"D:\Result.html" nicconfig where (IPEnabled=TRUE and DHCPEnabled=FALSE) call SetDNSServerSearchOrder ("9.1.1.1","10.1.1.1") 

回答

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中使用适当的小命令为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) }