How to remotely list the full member-names of an localgroup

Hi I created a vbscript to verify if a certain user is member of a local group.
This works fine except that some members aren't shown completely
my script leave everything in front of the backslash '\' and this is the problem
I need the full name because I want to know if "EU\Domain Admins" is a member of the
local administrators group

my Script:

[code]
strComputer = "PCname"
strGroup = "Administrators"
WScript.Echo "Checking " & strGroup &" Members of: " & strComputer
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")

For Each objMember In objGroup.Members
  WScript.Echo vbTab & objMember.Name
Next
[/code]

this script returns:
[b]
Checking Administrators Members of: .
      Administrator
      LNSS_MONITOR_USR
      Admini
      Domain Admins
      wilfy
      SYSTEM
      NETWORK SERVICE
      Domain Admins
      LOCAL_IT
[/b]
As you can see it doesn't show  the complete member-names
with this info I can't check for the member "EU\Domain Admins"



while [b]"net localgroup administrators"[/b] results
[b]
Members
-----------------------------------
Administrator
LNSS_MONITOR_USR
NT AUTHORITY\NETWORK SERVICE
NT AUTHORITY\SYSTEM
TA\Domain Admins
TA\LOCAL_IT
EU\Domain Admins
EU\wilfy
[/b]

any solutions to show the complete member-names in the vbscript?

thx
LVL 3
joachim.claeys@teleatlas.comAsked:
Who is Participating?
 
RobSampsonCommented:
You will need to check the ADsPath property, which will include the local computer name if the account is a local one.
'=============
strComputer = "maroonda-b09caa"
strGroup = "Administrators"
WScript.Echo "Checking " & strGroup &" Members of: " & strComputer
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")

For Each objMember In objGroup.Members
      If InStr(objMember.ADsPath, strComputer) > 0 Then
            WScript.Echo vbTab & "Local account: " & objMember.ADsPath
      Else
            WScript.Echo vbTab & "Domain account: " & objMember.ADsPath
      End If
Next
'===========

Regards,

Rob.
0
 
The_KirschiCommented:
Hi,

try:

WScript.Echo vbTab & objMember.cn

or

WScript.Echo vbTab & objMember.distingushedname

instead of:

WScript.Echo vbTab & objMember.Name

Hope this helps.
0
 
The_KirschiCommented:
You could also try:

WScript.Echo vbTab & objMember.FullName
0
 
The_KirschiCommented:
Sorry for my unqualified answer. At the moment when I wrote my answer I had no possibility to check if it worked. Obviously it doesn't as I found out right now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.