Exists user in administrators group?

(imported topic written by TommyG91)

I’ve looked at a few of Ben’s posts here but I can’t find what I’m looking for. I just need to be able to query to see if a user exists on a computer, and if it’s in the adminitrators group, and to be able to add / delete users. Is this possible? I can’t find any documentation on it.

Thanks

(imported comment written by pmullins91)

I use these in a pinch when I need to manage groups belonging to the local admin group. It imagine it will work with accounts local to the target box as well.

I use this relevance to find boxes missing a particular group:

not exists members whose (it as string as lowercase = "domain\accountName" as lowercase) of local group "Administrators"

And this action script to add new then remove old groups or users the local admin group on the target PCs:

waithidden {pathname of system x32 folder & "\cmd.exe"} /c for /d %x in (domain\GroupFoo domain\GroupBar) do net localgroup administrators %x /add
 
waithidden {pathname of system x32 folder & "\cmd.exe"} /c for /d %x in (domain\oldGroupOne domain\oldGroupTwo) do net localgroup administrators %x /delete