I'm trying to retrieve what groups the computer object is a part of but I am having a issues. One when I run the script below I am getting this error:
"The directory property cannont be found in the cache." on this line 'strGroups = objComputer.GetEx("memberOf ")'
Second how can I run this remotely against a computer to get the information without having to have the script actually running on the box?
"The directory property cannont be found in the cache." on this line 'strGroups = objComputer.GetEx("memberOf ")'
Second how can I run this remotely against a computer to get the information without having to have the script actually running on the box?
Code:
Dim WSHShell, objNET, objSysInfo, objComputer, strComputerDN, strGroups, Group, GroupName
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set objNET = WScript.CreateObject("WScript.Network")
Set objSysInfo = WScript.CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.COMPUTERNAME
Set objComputer = GetObject("LDAP://" & strComputerDN) 'Binds the objComputer to the Distiguished Name of the Computer in reference
strGroups = objComputer.GetEx("memberOf ")
For Each Group in strGroups
Set ThisGroup = GetObject("LDAP://" & Group)
GroupName = ThisGroup.CN
WScript.Echo GroupName
Next