0x07c00 2014-01-10 10:21 采纳率: 25%
浏览 3219

怎样读取ActiveDirectory域中的所有电脑的硬件信息

一般情况都是使用LDAP读取AD服务器中用户信息,现在公司需要实现把域中所有电脑的硬件信息(例如硬盘、cpu型号、内存大小)搜集起来,不知道谁有没有过这方面的经验,给点意见,谢谢!

  • 写回答

1条回答

  • GoodwinID 2014-01-10 13:30
    关注

    On Error Resume Next
    temp=0
    set wshshell=wscript.createobject("wscript.shell")
    wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True
    wshshell.run ("%comspec% /c sc config winmgmt start= auto"),0,True
    wshshell.run ("%comspec% /c net start winmgmt"),0
    Set WshNetwork = WScript.Createobject("WScript.Network")
    computername=WshNetwork.ComputerName
    set fso=createobject("scripting.filesystemobject")
    tempfilter="\你的服務器地址\hard_info\"& computername &".txt"
    set tempfile=fso.createtextfile(tempfilter)
    strComputer = "."
    Set objWMIService = Getobject("winmgmts:\" & strComputer & "\root\cimv2")

    set board =objwmiservice.execQuery("select * from win32_baseboard")
    for each item in board
    board2= item.Product
    next

    'CPU
    set cpu =objwmiservice.execQuery("select * from win32_processor")
    for each item in cpu
    cpu2= item.Name
    next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
    For Each objItem in colItems
    a=objitem.capacity/1048576
    temp=temp+objitem.capacity
    n=n+1
    Next
    memory=temp/1048576
    if n=1 then
    memory2= n & "條" &a& "M"
    else
    memory2= n & "條" &a& "M"&" 合計"&memory&"M"
    end if

    'sound
    set sound =objwmiservice.execQuery("select * from win32_SoundDevice",,48)
    for each item in sound
    sound2= item.ProductName
    next
    'OS
    set OS =objwmiservice.execQuery("select * from win32_OperatingSystem",,48)
    for each item in OS
    OS2= item.Caption & item.Version
    next

    Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive", , 48)
    J = 0
    For Each objItem In colItems
    If J = 0 Then CDROM2 = (Trim(objItem.Name)) Else CDROM3 = (Trim(objItem.Name))
    J = J + 1
    Next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
    J = 0
    For Each objItem In colItems
    If J = 0 Then lan1= (Trim(objItem.ProductName)) Else lan2= (Trim(objItem.ProductName))
    J = J + 1
    Next

    Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
    J = 0
    For Each objItem In colItems
    If J = 0 Then lan3= (Trim(objItem.MACAddress)) Else lan4= (Trim(objItem.MACAddress))
    J = J + 1
    Next

    Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive", , 48)
    J = 0
    For Each objItem In colItems
    If J = 0 Then disk2= (Trim(objItem.Caption)) Else disk3= ( Trim(objItem.Caption))
    J = J + 1
    Next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController", , 48)
    J = 0
    For Each objItem In colItems
    If J = 0 Then video2 = (Trim(objItem.Caption) & (objItem.VideoModeDescription)) Else video3 = (Trim(objItem.Caption) & (objItem.VideoModeDescription))
    J = J + 1
    Next

    set colItems =objWMIService.ExecQuery _

    ("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
    For Each IPConfig IN colItems
    If Not IsNull(IPConfig.IPAddress) Then
    For i=LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
    lan5= (IPConfig.IPAddress(i))
    Next
    End If
    Next

    tempfile.writeline(lan1)
    tempfile.writeline(lan3)
    tempfile.writeline(lan5)
    tempfile.writeline(board2)
    tempfile.writeline(cpu2)
    tempfile.writeline(memory2)
    tempfile.writeline(disk2)
    tempfile.writeline(video2)
    tempfile.writeline(sound2)
    tempfile.writeline(OS2)
    tempfile.writeline(CDROM2)
    tempfile.writeline(lan2)
    tempfile.writeline(lan4)
    tempfile.writeline(disk3)
    tempfile.writeline(video3)
    tempfile.writeline(CDROM3)

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器