2013-02-21 20 views
0

我有一个wmic命令我想运行它将查询计算机列表并返回csv文件(如果安装了修补程序)。在我的情况下,修补程序ID是2617858.它开始处理,然后在大约20秒后出现:error:desciption =异常发生。它在文件中有几台机器时工作,但我需要在40台计算机上运行它。WMIC错误:desciption =搜索修补程序时发生异常

有什么建议吗?由于

CODE:

wmic /failfast:on /node:@"C:\users\username\desktop\servers.txt" qfe | find "2617858" > \\computername\C$\users\username\desktop\hotfix.csv 

回答

0

对于它的价值,它可能要问wmic过滤而不是通过find管道wmic容易。事情是这样的:

wmic /node:@"C:\users\username\desktop\servers.txt" qfe where hotfixid="KB983590" get csname /format:list >>hotfix.txt 

或者,如果问题是wmic无法处理多台服务器在servers.txt,试图通过列表与一批for回路循环。

@echo off 
setlocal 
for /f "usebackq delims=" %%I in ("C:\users\username\desktop\servers.txt") do (
    set /P "=Checking %%I... " 
    wmic /node:%%I qfe where hotfixid="KB983590" get csname /format:list >>hotfix.txt 2>>failures.txt 
    echo Done. 
) 
echo Unable to query the following computers: 
type failures.txt 

作为替代方案,您可以使用PowerShell执行相同的操作。

powershell -command "$pcs = Get-Content C:\users\username\desktop\servers.txt; foreach ($pc in $pcs) { Get-WmiObject -Computername $pc Win32_QuickFixEngineering | where-object {$_.hotfixid -eq 'KB980232'} | select-object csname }" >>hotfix.txt 

...虽然如果wmi在服务器上对wmic没有响应,那么使用powershell可能不会有更好的运气。

相关问题