Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-08-03
4
Medium Priority
?
865 Views
Last Modified: 2010-08-05
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
0
Comment
  • 3
4 Comments
 
LVL 16

Expert Comment

by:The_Kirschi
ID: 19626085
Hi,

try:

WScript.Echo vbTab & objMember.cn

or

WScript.Echo vbTab & objMember.distingushedname

instead of:

WScript.Echo vbTab & objMember.Name

Hope this helps.
0
 
LVL 16

Expert Comment

by:The_Kirschi
ID: 19626247
You could also try:

WScript.Echo vbTab & objMember.FullName
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 1500 total points
ID: 19633073
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
 
LVL 16

Expert Comment

by:The_Kirschi
ID: 19633445
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question