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
对于 Windows 客户端,您可以使用 WMI 脚本来获取它。此处的信息应该可以帮助您入门。
感谢@mh 提供到 WMI 的链接。这是我最终得到的脚本。
您可以通过 SCOM 做到这一点,但老实说,这是一把大锤子。