查找 Windows 网络上所有机器的屏幕分辨率的最简单方法是什么?

查找 Windows 网络上所有机器的屏幕分辨率的最简单方法是什么?

我不想跑来跑去逐个检查每台机器,有没有可以使用的服务器端软件?这是一个混合的 Linux/Windows 网络(客户端和服务器),但我只对 Windows 客户端感兴趣。

答案1

对于 Windows 客户端,您可以使用 WMI 脚本来获取此信息。这里应该可以帮助你入门。

答案2

感谢@mh 提供的 WMI 链接。这是我最终得到的脚本。

On Error resume next

strDomain = "domain.local"

Set objFSO = CreateObject("Scripting.FileSystemObject")
if err.number <> 0 then Wscript.quit

set domObj = GetObject("WinNT://" & strDomain)
domObj.Filter = Array("computer")
For Each objComputer In domObj
    err.clear
    strComputer = objComputer.Name
    computerName = "UNKNOWN"
    loggedOnUser =""
    sp = ""
    ram = ""
    cpu = ""
    cpuMhz = ""
    xres = ""
    yres = ""

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    if err.number=0 then
    ' Query "BIOS" properties
    ' computer name
    Set colItems = objWMIService.ExecQuery("Select * From Win32_BIOS")
    For Each objItem in colItems
        computerName = objItem.Path_.Server
    Next

    ' Query Processor properties
    ' Family
    ' ...
    Set colItems = objWMIService.ExecQuery("Select * From Win32_Processor")
    For Each objItem in colItems
        cpu = objItem.Manufacturer & " " & objItem.Name
        cpuMhz = objItem.MaxClockSpeed
    Next

    ' Query Operating System properties
    ' SP Level
    ' RAM
    Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
    For Each objItem in colItems
        sp = objItem.ServicePackMajorVersion
        ram = objItem.TotalVisibleMemorySize
    Next

    ' Query Computer System properties
    ' User
    Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystem")
    For Each objItem in colItems
        loggedOnUser = objItem.UserName
    Next

    ' Query Display properties
    ' Screen resolution
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DisplayConfiguration")
        For Each objItem in colItems
            xres = objItem.PelsWidth
            yres = objItem.PelsHeight
        Next

        strFile = "\\server\data\inventory\" & computerName & ".txt"

        Set objTextFile = objFSO.OpenTextFile(strFile, 2, True)
        if err.number <> 0 then Wscript.quit

        objTextFile.WriteLine("Computer Name: " & strComputer)
        if err.number <> 0 then Wscript.quit

    if loggedOnUser <> "" then objTextFile.WriteLine("User: " & loggedOnUser)
    if cpu <> "" then objTextFile.writeLine("CPU: " & cpu)
    if cpuMhz <> "" then objTextFile.writeLine("CPU MHZ: " & cpuMhz)
    if ram <> "" then objTextFile.WriteLine("RAM: " & ram)
    if sp <> "" then objTextFile.WriteLine("Service Pack: " & sp)
    if xres <> "" then objTextFile.WriteLine("Horizontal resolution: " & xres)
    if yres <> "" then objTextFile.WriteLine("Vertical resolution: " & yres)

        objTextFile.Close

    end if
next

答案3

您可以通过 SCOM 来做到这一点,但说实话,它是用大锤敲小坚果。

相关内容