Hi,
I have a wmi query that won't work and i just don't know why. I'm completely stuck and i'm not sure what to do. I am very new to scripting unfortunately and i'm trying to learn.
I have a script which runs wmi queries to servers which works successfully. It reads from a text file containing ip addresses and then writes the collected information to a .csv file. An example of a query is below:
set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem In colItems
StrComputerName= objItem.Caption
StrManufacturer = objItem.Manufacturer
strModel = objItem.Model
strCaption2 = objItem.Caption
strSystemType = objItem.SystemType
strDomain = objItem.Domain
strOwner = objItem.PrimaryOwnerName
strName = objItem.Name
next
All the values eg, strName, strDomain have been declared in a Dim statement.
The tricky bit which has me confused is that for these servers, i need to get some of their information from Active Directory as well. The information i need is in the wmi namespace called root\directory\LDAP and the wmi class is called ds_computer.
I amended my original script with the appropriate name space and class, but nothing is written to the.csv file apart from the server's ip address. The amended bit is
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\directory\LDAP")
Set colItems = objWMIService.ExecQuery("SELECT * FROM ds_computer",,48)
For Each objItem In colItems
strServerDescription = strDS_description
next
Can anybody see where i am going wrong and point me in the right direction please?
Thank you,
H
I have a wmi query that won't work and i just don't know why. I'm completely stuck and i'm not sure what to do. I am very new to scripting unfortunately and i'm trying to learn.
I have a script which runs wmi queries to servers which works successfully. It reads from a text file containing ip addresses and then writes the collected information to a .csv file. An example of a query is below:
set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem In colItems
StrComputerName= objItem.Caption
StrManufacturer = objItem.Manufacturer
strModel = objItem.Model
strCaption2 = objItem.Caption
strSystemType = objItem.SystemType
strDomain = objItem.Domain
strOwner = objItem.PrimaryOwnerName
strName = objItem.Name
next
All the values eg, strName, strDomain have been declared in a Dim statement.
The tricky bit which has me confused is that for these servers, i need to get some of their information from Active Directory as well. The information i need is in the wmi namespace called root\directory\LDAP and the wmi class is called ds_computer.
I amended my original script with the appropriate name space and class, but nothing is written to the.csv file apart from the server's ip address. The amended bit is
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\directory\LDAP")
Set colItems = objWMIService.ExecQuery("SELECT * FROM ds_computer",,48)
For Each objItem In colItems
strServerDescription = strDS_description
next
Can anybody see where i am going wrong and point me in the right direction please?
Thank you,
H