See the code below....
I cannot figure out why the If statement is not executing properly. I think I have the syntax correct but I do not get the wscript.echo portion of the if statement to work.
I have tried to trim the leading and trailing spaces also, but I cannot figure out what I'm doing wrong. Help!!!
Option Explicit
Dim strComputer, objWMIService, colSettings, objComputer, compModel
Dim DellGX150, DellC600
DellGX150 = "OptiPlex GX150"
DellC600 = "Latitude C600"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem"
For Each objComputer in colSettings
Wscript.Echo objComputer.Model
compModel = objComputer.Model
Next
If compModel = "DellGX150" then
Wscript.Echo "Computer is " & compModel
elseif compModel = DellC600 then
Wscript.Echo "Computer is " & compModel
End If
I cannot figure out why the If statement is not executing properly. I think I have the syntax correct but I do not get the wscript.echo portion of the if statement to work.
I have tried to trim the leading and trailing spaces also, but I cannot figure out what I'm doing wrong. Help!!!
Option Explicit
Dim strComputer, objWMIService, colSettings, objComputer, compModel
Dim DellGX150, DellC600
DellGX150 = "OptiPlex GX150"
DellC600 = "Latitude C600"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem"
For Each objComputer in colSettings
Wscript.Echo objComputer.Model
compModel = objComputer.Model
Next
If compModel = "DellGX150" then
Wscript.Echo "Computer is " & compModel
elseif compModel = DellC600 then
Wscript.Echo "Computer is " & compModel
End If