I'm new to scripting and programming.
In the following and similar scripts, I noticed that there exists a 'objOperatingSystem' that is referred to in the 'For Each' loop. I understand that 'colSettings' is a variable that contains the WMI collection, but where does the 'objOperatingSystem' come from ?
Pls help. Thanks!!!
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
Wscript.Echo "Available Physical Memory: " & _
objOperatingSystem.FreePhysicalMemory
Next
objOperatingSystem
is a variable. For Each
declared it. Basically, for every item in colSettings
a variable named objOperatingSystem
will be set to the current item, and the body of the for loop executed.