Here is the entire code
JustinEzequiel, Ive been running it without the quotes as well. I was trying different things in an attempt to find out what the issue is.
Option Explicit
'On Error Resume Next
Dim wmiRoot
Dim WshShell
Dim objWMIService
Dim colItems
Dim objItem
Dim strComputerName
Dim dellAssestTag
Dim Suffix
Dim vmCores 'Used to count number of cores for virtual
Const wbemFlagReturnImmediately = &h10 'Constant for using Win32_OperatingSystem class
Const wbemFlagForwardOnly = &h20 'Constant for using Win32_OperatingSystem, class
Const IEVersion = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version"
wmiRoot = "winmgmts:\\.\root\cimv2" 'Assigns WMI root to a variable
Set objWMIService = GetObject(wmiRoot)
Set WshShell = WScript.CreateObject("WScript.Shell")
'Pulls Computer Name
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strComputerName = objItem.Name
WScript.Echo "Computer Name: " & strComputerName
Next
'Ends Pull Computer Name
'Pulls Operating System and Service Pack Version
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "Operating System: " & objItem.Caption
WScript.Echo "ServicePack: SP " & objItem.ServicePackMajorVersion
Next
'End Pulls Operating System and Service Pack Version
'Pulls Dell Assest Tag and Server Type
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
If IsVM Then
WScript.Echo "Server Type: Virtual"
WScript.Echo "Service Tag: N/A"
Else
WScript.Echo "Server Type: Physical"
WScript.Echo "SerialNumber: " & objItem.SerialNumber
End If
Next
'End Pull Dell Assest Tag and Server Type
'Pull CPU Speed and Number of cores
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "NumberOfCores: " & objItem.NumberOfCores
WScript.Echo "CPU Speed: " & Round(objItem.CurrentClockSpeed / 1000, 2) & " GHz"
Next
'End Pull CPU Speed and Number of cores
'Allocated RAM
Set colItems = objWMIService.ExecQuery( "Select * FROM Win32_ComputerSystem")
For Each objItem in colItems
WScript.Echo "RAM: " & ConvertBytes(objItem.TotalPhysicalMemory)
Next
'Network Adapters
Dim NumNetworkPorts
Set colItems = objWMIService.ExecQuery("Select * FROM Win32_NetworkAdapter WHERE PhysicalAdapter=True")
For Each objItem In colItems
NumNetworkPorts=NumNetworkPorts + 1
Next
WScript.Echo "Number of NetworksPorts: " & NumNetworkPorts
'IE Version
WScript.Echo "IE Version: Version " & Left(((WshShell.RegRead (IEVersion))),3)
'Number of Hard Drives
Dim HardDrives
Set colItems = objWMIService.ExecQuery("Select * FROM Win32_LogicalDisk WHERE DriveType=3")
For Each objItem In colItems
HardDrives=HardDrives + 1
Next
WScript.Echo "Number of Hard Drives: " & HardDrives
'C Drive usage
Set colItems = objWMIService.ExecQuery("Select * FROM Win32_LogicalDisk WHERE DeviceID='C:'")
For Each objItem in colItems
WScript.Echo "C Drive: " & ConvertBytes(objItem.Size - objItem.FreeSpace) & " free out of " & ConvertBytes(objItem.Size) &_
" total"
Next
'Socket Type
'Set colItems = objWMIService.ExecQuery("Select * FROM Win32_Processor")
'For Each objItem In colItems
' WScript.Echo"Socket Type: " & objItem.SocketDesignation
'Next
'IP Address
Set colItems = objWMIService.ExecQuery("Select * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
WScript.Echo"IP Address: " & objItem.IPAddress(0)
Next
'PageFile Settings
Set colItems = objWMIService.ExecQuery("Select * FROM Win32_PageFileUsage")
For Each objItem in colItems
WScript.Echo "PageFile: Allocated - " & ConvertMB(objItem.AllocatedBaseSize) & " Usage - " &_
ConvertMB(objItem.CurrentUsage)
Next
'**********Function that convert bytes up to Terabytes**********
Function ConvertBytes(Size)
Do While InStr(Size,",") 'Remove commas from size
CommaLocate = InStr(Size,",")
Size = Mid(Size,1,CommaLocate - 1) & _
Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate)
Loop
Suffix = " Bytes"
If Size >= 1024 Then suffix = " KB"
If Size >= 1048576 Then suffix = " MB"
If Size >= 1073741824 Then suffix = " GB"
If Size >= 1099511627776 Then suffix = " TB"
Select Case Suffix
Case " KB" Size = Round(Size / 1024, 2)
Case " MB" Size = Round(Size / 1048576, 2)
Case " GB" Size = Round(Size / 1073741824, 2)
Case " TB" Size = Round(Size / 1099511627776, 2)
End Select
ConvertBytes = Size & Suffix
End Function
'**********Function that convert Megabytes up to Exabytes**********
Function ConvertMB(Size)
Size = CSng(Replace(Size,",",""))
If Not VarType(Size) = vbSingle Then
ConvertMB = "SIZE INPUT ERROR"
Exit Function
End If
Suffix = " MB"
If Size >= 1024 Then suffix = " GB"
If Size >= 1048576 Then suffix = " TB"
If Size >= 1073741824 Then suffix = " PB"
If Size >= 1099511627776 Then suffix = " EB"
Select Case Suffix
Case " GB" Size = Round(Size / 1024, 2)
Case " TB" Size = Round(Size / 1048576, 2)
Case " PB" Size = Round(Size / 1073741824, 2)
Case " EB" Size = Round(Size / 1099511627776, 2)
End Select
ConvertMB = Size & Suffix
End Function
'**********Function to determine Virtual Machine**********
Function IsVM ()
Dim isvmItems
Set isvmItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In isvmItems
If objItem.Manufacturer = "VMware, Inc." Then
IsVM = True
Else
IsVM = False
End If
Next
End Function