2017-01-10 115 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) }