Login Script to gather System Information

DCRJDS
DCRJDS used Ask the Experts™
on
I need a Windows Server 2003 Login Script to gather System Information from domain users.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
not enough information....  please add

Author

Commented:
I need to capture ComputerName, CPU, Memory, Harddrive information.    
Commented:
usage

script.vbs /computer:(computer name)

'*****************************************************

'
' CPU:
'      - CPU Speed MHZ
'      - CPU Manufacture
'      - CPU Type
'      - CPU Current Load
'
' Memory
'      - Memory Bank
'      - Memory Stick Size MB
'      - Memory Speed MHZ
'      - Memory Type
'
' Hard Drive
'      - HD Model
'      - HD Size GB
'      - HD # of Partions
'      - HD Type
'      - Drive Letter
'      - Used Space
'      - Free Space
'      - Size of Partion
'      - Free Space %
'
' Script Usage:
' cscript hardware.vbs /computer:[Computer Name]
'*****************************************************
On Error Resume Next
' Dims stuff
Dim objStdOut,args
Dim servername
' Set Stuff
Set objStdOut = Wscript.stdOut
Set args = Wscript.Arguments.Named
servername = trim(args.Item("computer"))

if wscript.arguments.count = 1 then
      wscript.echo "CPU,Memory,Hard Drive Information for " & ucase(servername)
      wscript.echo ""
      if not (errorChecking (servername)) then
                  '// CPU Info
                  wscript.echo "CPU Information:"
                  wscript.echo "================"
                  For each objCPU in GetObject("winmgmts:{impersonationLevel=impersonate}\\" & servername & "\root\cimv2").InstancesOf("Win32_Processor")
                        Select Case objCPU.Family
                              Case 2
                                    cputype = "Unknown"
                              Case 11
                                    cputype = "Pentium brand"
                              Case 12
                                    cputype = "Pentium Pro"
                              Case 13
                                    cputype = "Pentium II"
                              Case 14
                                    cputype = "Pentium processor with MMX technology"
                              Case 15
                                    cputype = "Celeron "
                              Case 16
                                    cputype = "Pentium II Xeon"
                              Case 17
                                    cputype = "Pentium III"
                              Case 28
                                    cputype = "AMD Athlon Processor Family"
                              Case 29
                                    cputype = "AMD Duron Processor"
                              Case 30
                                    cputype = "AMD2900 Family"
                              Case 31
                                    cputype = "K6-2+"
                              Case 130
                                    cputype = "Itanium Processor"
                              Case 176
                                    cputype = "Pentium III Xeon"
                              Case 177
                                    cputype = "Pentium III Processor with Intel SpeedStep Technology"
                              Case 178
                                    cputype = "Pentium 4"
                              Case 179
                                    cputype = "Intel Xeon"
                              Case 181
                                    cputype = "Intel Xeon processor MP"
                              Case 182
                                    cputype = "AMD AthlonXP Family"
                              Case 183
                                    cputype = "AMD AthlonMP Family"
                              Case 184
                                    cputype = "Intel Itanium 2"
                              Case 185
                                    cputype = "AMD Opteron™ Family"
                        End Select
                        wscript.echo " CPU MHZ: " & objCPU.CurrentClockSpeed
                        wscript.echo " CPU Manufacture: " & objCPU.Manufacturer
                        wscript.echo " CPU Type: " & cputype
                        wscript.echo " CPU Current Load: " & objCPU.LoadPercentage & "%"
                  next
                  wscript.echo ""
                  set objCPU = nothing
                  
                  '// Memory Info
                  wscript.echo "Memory Information:"
                  wscript.echo "==================="
                  For Each objMem In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & servername & "\root\cimv2").InstancesOf("Win32_PhysicalMemory")
                        Select Case objMem.MemoryType
                              Case 0
                                    rtype = "Unknown"
                              Case 1
                                    rtype = "Other"
                              Case 2
                                    rtype = "DRAM"
                              Case 3
                                    rtype = "Synchronous DRAM"
                              Case 4
                                    rtype = "Cache DRAM"
                              Case 5
                                    rtype = "EDO"
                              Case 6
                                    rtype = "EDRAM"
                              Case 7
                                    rtype = "VRAM"
                              Case 8
                                    rtype = "SRAM"
                              Case 9
                                    rtype = "RAM"
                              Case 10
                                    rtype = "ROM"
                              Case 11
                                    rtype = "Flash"
                              Case 12
                                    rtype = "EEPROM"
                              Case 13
                                    rtype = "FEPROM"
                              Case 14
                                    rtype = "EPROM"
                              Case 15
                                    rtype = "CDRAM"
                              Case 16
                                    rtype = "3DRAM"
                              Case 17
                                    rtype = "SDRAM"
                              Case 18
                                    rtype = "SGRAM"
                              Case 19
                                    rtype = "RDRAM"
                              Case 20
                                    rtype = "DDR"
                        End Select
                        wscript.echo " Memory Bank: " &  objMem.BankLabel
                        wscript.echo " Memory Size: " & objMem.Capacity/1024/1024 & " MB"
                        wscript.echo " Memory Speed: " & objMem.Speed & " MHZ"
                        wscript.echo " Memory Type: " & rtype
                        wscript.echo ""
                  next
                  wscript.echo ""
                  set objMem = nothing
                  
                  '// Hard Drive Info
                  wscript.echo "Hard Drive Information:"
                  wscript.echo "======================="
                  For Each objHDInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & servername & "\root\cimv2").InstancesOf("Win32_DiskDrive")
                        wscript.echo " Hard Drive Model: " & objHDInfo.Model
                        wscript.echo " Hard Drive Size: " & clng(objHDInfo.Size/1024/1024/1024) & " GB"
                        wscript.echo " # of Partitions: " & objHDInfo.Partitions
                        wscript.echo " Hard Drive Type: " & objHDInfo.InterfaceType
                        wscript.echo ""
                  Next
                  wscript.echo ""
                  set objHDinfo = nothing
                              
                  For Each objDisk In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & servername & "\root\cimv2").InstancesOf("Win32_LogicalDisk Where DriveType = '3'")
                        freespace = left(objDisk.freespace/1024/1024/1024,4)
                        totalspace = left(objDisk.size/1024/1024/1024,4)
                        usedspace = left(totalspace/freespace,4)
                        freeperct = left(100/usedspace,2)
                        wscript.echo " Drive: " & objDisk.deviceid
                        wscript.echo " Used Space: " & usedspace & " GB"
                        wscript.echo " Free Space: " & freespace & " GB"
                        wscript.echo " Total Space: " & totalspace & " GB"
                        wscript.echo " Free: " & freeperct & "%"
                        wscript.echo ""
                  next
                  set objDisk = nothing
      end if
      wscript.echo "------------------------------------------------"
else
      objStdOut.Write "Usage: cscript hardware.vbs /computer:[Computer Name]"
      objStdOut.close
      wscript.quit
end if

' Error Checking Function
Function errorChecking(ComputerName)
errorChecking = False
if err.number <> 0 then
      if err.number = "462" then
            wscript.echo ComputerName & ",Error,Unable to connect"
                  err.Clear ()
                  errorChecking = True
      elseif err.number = "70" then   'General access denied error
            wscript.echo ComputerName & ",Error,Permission Denied while trying to connect."
                  err.Clear ()
                 errorChecking = True
      elseif err.number = "451" then      'HEX Error is: 1C3
                  err.Clear ()
                 errorChecking = True
         elseif err.number = "-2147023174" then   'The RPC server is unavailable.
            wscript.echo ComputerName & ",Error,Unable to connect error number -2147023174."
                  err.Clear ()
                 errorChecking = True
      elseif err.number = "-2147023836" then
            wscript.echo ComputerName & ",Error,Unable to connect error number --2147023836."
                  err.Clear ()
                 errorChecking = True
      elseif err.number = "-2147022986" then
            wscript.echo ComputerName & ",Error,Unable to connect error number -2147022986."
                  err.Clear ()
                 errorChecking = True
      else
            wscript.echo "Error is: " & err.number
            wscript.echo "HEX Error is: " & hex(err.number)
            wscript.echo "Desc. is: " & err.Description
            wscript.echo "Source is: " & err.Source
            err.Clear ()
      end if
end if
end Function

Author

Commented:
Our network guy says he can use it.  Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial