B
Berger, Daniel
Hi all,
Ruby 1.8.2
Windows XP
Are there any known issues with using associators and win32ole?
Consider the following example. Using the first query below, I get four
rows back that look like this:
"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"MYDOMAIN\",Name=3D=
\"
System Account\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Domain
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Desktop
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"AD\",Name=3D\"djb=
erg
e\""
However, I'd like to get back the actual Win32_UserAccount objects
instead of plain strings. When I try to use associators, I get no
results. What am I doing wrong?
Thanks.
Dan
# assoctest.rb
require "win32ole"
require "socket"
host =3D Socket.gethostname
cs =3D "winmgmts://#{host}/root/cimv2"
# For local groups, you probably want to replace 'MYDOMAIN' with your
host name.
# This returns partcomponent as a String
query =3D "
SELECT *
FROM Win32_GroupUser
WHERE
groupcomponent=3D\"Win32_Group.Domain=3D'MYDOMAIN',Name=3D'Administrators=
'\"
"
# This should return partcomponent as a Win32_UserAccount object, but
instead returns nothing
#query =3D "
# associators of {Win32_Group.Domain=3D'MYDOMAIN',
Name=3D'Administrators'}
# where resultclass =3D Win32_UserAccount AssocClass =3D =
Win32_GroupUser
#"
wmi =3D WIN32OLE.connect(cs)
wmi.execquery(query).each{ |m|
p m.partcomponent
}
Ruby 1.8.2
Windows XP
Are there any known issues with using associators and win32ole?
Consider the following example. Using the first query below, I get four
rows back that look like this:
"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"MYDOMAIN\",Name=3D=
\"
System Account\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Domain
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Desktop
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"AD\",Name=3D\"djb=
erg
e\""
However, I'd like to get back the actual Win32_UserAccount objects
instead of plain strings. When I try to use associators, I get no
results. What am I doing wrong?
Thanks.
Dan
# assoctest.rb
require "win32ole"
require "socket"
host =3D Socket.gethostname
cs =3D "winmgmts://#{host}/root/cimv2"
# For local groups, you probably want to replace 'MYDOMAIN' with your
host name.
# This returns partcomponent as a String
query =3D "
SELECT *
FROM Win32_GroupUser
WHERE
groupcomponent=3D\"Win32_Group.Domain=3D'MYDOMAIN',Name=3D'Administrators=
'\"
"
# This should return partcomponent as a Win32_UserAccount object, but
instead returns nothing
#query =3D "
# associators of {Win32_Group.Domain=3D'MYDOMAIN',
Name=3D'Administrators'}
# where resultclass =3D Win32_UserAccount AssocClass =3D =
Win32_GroupUser
#"
wmi =3D WIN32OLE.connect(cs)
wmi.execquery(query).each{ |m|
p m.partcomponent
}