Hi, all,
I am very new to scripting. Need your help on handling string comparison. I am trying to check whether a pc model matches, eg., "OpliPlex GX260". However, it seems that it is having difficulty with the space between "OpliPlex" and "GX260".
Here are somelines from my script:
REM Getting the value of pc model
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
pcmodel = objItem.Model
Next
rem If pc model is "gx240" then check marker file. Then either exit or continue to implement the security template import.
IF pcmodel = "OpliPlex GX240" then
execute certain command
End If
If I echo the objItem.Model when executing the script on a Dell OpliPlex GX240, the displays the model as "OpliPlex GX240". I have also tried:
pcmodel = Rtrim(objItem.Model) hoping to eleminate the spaces before and after. But still the IF condition does not satisfy even when I run this script on a GX240 machine. Could you please help?
I am very new to scripting. Need your help on handling string comparison. I am trying to check whether a pc model matches, eg., "OpliPlex GX260". However, it seems that it is having difficulty with the space between "OpliPlex" and "GX260".
Here are somelines from my script:
REM Getting the value of pc model
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
pcmodel = objItem.Model
Next
rem If pc model is "gx240" then check marker file. Then either exit or continue to implement the security template import.
IF pcmodel = "OpliPlex GX240" then
execute certain command
End If
If I echo the objItem.Model when executing the script on a Dell OpliPlex GX240, the displays the model as "OpliPlex GX240". I have also tried:
pcmodel = Rtrim(objItem.Model) hoping to eleminate the spaces before and after. But still the IF condition does not satisfy even when I run this script on a GX240 machine. Could you please help?