Relevance for querying local admin users and hostnames

(imported topic written by ktakada91)

I am interested in finding out who has local admin rights on workstations. But when I also tried to get the host names of the machines where those users are found, I get the singular expression is required error. I understand why I get this error since there are multiple local admin users on each workstation. Is there a syntax I can use to get a result like:

usera - host1

userb - host1

userc - host2

userd - host3

usere - host3

userf - host3

q: if exists (local group “Administrators”) then (members of local group “Administrators” as string & " - " & hostnames as string) else (“No Local Admin Group”)

E: A singular expression is required.

Any advice would be appreciated. Thanks,

Kotaro Takada

(imported comment written by NoahSalzman)

Do you not like the output from this version…

if (exists local group “Administrators”) then (members of local group “Administrators” as string) else (“No Local Admin Group”)

… because of the backslash? I get HOSTNAME\username when I run that.

(imported comment written by MrFixit)

The issue you had is with concatenation “&”. Doing something like the example below with “it” can help get that style of result.

if (exists local group “Administrators”) then (it & " - " & (hostname)) of (members of local group “Administrators” as string) else (“No Local Admin Group”)

For me… I would just use what noah posted. Your analysis will show what host it came from.

(imported comment written by ktakada91)

Thanks, Noah and MrFixit. I did need (it & " - " & (hostname)) because the relevance returns a lot of ad\username. It works great. Thanks again!