List local administrators (and then filter the output)

(imported topic written by SATO91)

Hi,

I’d like to list the members of the local group “Administrators” and then filter out a group that I know exist on all machines and that shouldn’t be listed in the results.

Q:

members of local group “Administrators”

A: (for SERVER_A)

SERVER_A\Administrator

CORP\Domain Admins

CORP\Finance Admins

CORP\Finance Consultants

CORP\JohnB

CORP\SallyJ

A: (for SERVER_F)

SERVER_F\Administrator

CORP\Domain Admins

CORP\Marketing Admins

CORP\Reviewer Consultants

CORP\JohnB

CORP\TimL

CORP\PatricU

Is there a way where I can filter the result to only display users and groups from the CORP domain but to rule out Domain Admins (that I know exist on all my servers)?

I’ve tried

Q: members of local group “Administrators” whose (name of it “CORP\Domain Admins”)

…and various other questions, but I’m unable to filter the results.

I hope someone can point me in the right direction. Thanks!

//Samir

1 Like

(imported comment written by jessewk)

You’re very close… first, you need to move your whose clause to filter on the members object instead of the local group object.

Q: members whose (name of it “CORP\Domain Admins”) of local group “Administrators”

Next, 'members of ’ returns a object. objects only have 1 property: SID. There is no ‘name’ property. Instead, you can cast a to a

Q: members whose (it as string “CORP\Domain Admins”) of local group “Administrators”

Finally, the ‘not equals’ operator in the Relevance language is !=

Q: members whose (it as string != “CORP\Domain Admins”) of local group “Administrators”

This is the same:

Q: members whose (it as string is not equal to “CORP\Domain Admins”) of local group “Administrators”