回复 16# cj-reggie
批量做动作作为网管更要用WMI了,其实很简单的,有个批量检查BLOS中USB开关的码,希望对你有所帮助#include <file.au3>
#include <array.au3>
$file = @ScriptDir&"\result.ini"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
Dim $aRecord,$aRecords
Run(@ComSpec & " /c dsquery computer -o rdn -limit 1500 >"&@TempDir&"\adlist.txt","", @SW_HIDE);利用dsquery查询Active Directory所有PC name
Sleep(2000)
If Not _FileReadToArray(@TempDir&"\adlist.txt",$aRecord) Then;读取文件得到数组
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecord[0]-1
$aRecord[$x] =StringTrimRight((StringTrimLeft($aRecord[$x], 1)),1)
If Ping ($aRecord[$x],250) Then
If Ping ($aRecord[$x]) And DriveStatus( "\"&$aRecord[$x]&"\c$" ) = "UNKNOWN" Then;有些PC可能IP冲突,也有可能没有管理员权限,暂且定义为防火墙
IniWrite($file,"info",$aRecord[$x],"Firewall")
Else
$objWMIService = ObjGet("winmgmts:\" & $aRecord[$x] & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBController", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
If $objItem.Status= "OK" Then
iniWrite($file,"info",$aRecord[$x],"OK");USB开着的
Else
iniWrite($file,"info",$aRecord[$x],"NO");USB没问题
EndIf
Next
EndIf
Else
If TCPNameToIP($aRecord[$x])<>"" Then
IniWrite($file,"info",$aRecord[$x],"No boot");没开机
Else
IniWrite($file,"info",$aRecord[$x],"N/PC");没有的PC在AD中没有即时update
EndIf
EndIf
Next
|