(imported comment written by brolly3391)
Hello Tim,
This is a fun one. To combine the items you can use select objects instead of selects. This keeps the return from WMI grouped into objects and then you can pull properties from those objects. Put these into your relevance debugger to see what I am talking about. The bolding indicates where I added something new from the last line.
q: select objects (“Name,SID, Disabled from Win32_UserAccount”) of WMI
q:
string values of properties “SID” of
select objects (“Name,SID, Disabled from Win32_UserAccount”) of WMI
q: select objects (“Name,SID, Disabled from Win32_UserAccount”)
whose (exists string value of property “SID” of it)
of WMI
q: select objects (“Name,SID, Disabled from Win32_UserAccount”) whose (exists string value
whose (first 9 of it = “S-1-5-21-” and (last 4 of it ="-500" or last 4 of it = “-501”))
of property “SID” of it) of WMI
So now we have the 2 objects that are administrator and guest. You wanted their names, if they are disabled and if they were renamed so lets play with this.
q:
(property “name” of it as string & " - " & property “SID” of it as string & " - "& property “disabled” of it as string ) of
(select objects (“Name,SID, Disabled from Win32_UserAccount”) whose (exists string value whose (first 9 of it = “S-1-5-21-” and (last 4 of it ="-500" or last 4 of it = “-501”)) of property “SID” of it) of WMI)
A: name=Administrator - sid=S-1-5-21-1292428093-113007714-839522115-500 - disabled=False
A: name=Guest - sid=S-1-5-21-1292428093-113007714-839522115-501 - disabled=False
and lets add in a nested if/then/else to check for the renames on each account in turn:
q: (property “name” of it as string & "; " &
(if (string value of property “sid” of it ends with “-500” and string value of property “name” of it = “Administrator”) then (“Renamed=False”) else (if (string value of property “sid” of it ends with “-501” and string value of property “name” of it = “Guest”) then (“Renamed=False”) else (“Renamed=True”)))
& "; " & property “SID” of it as string & “; “& property “disabled” of it as string ) of (select objects (“Name,SID, Disabled from Win32_UserAccount”) whose (exists string value whose (first 9 of it = “S-1-5-21-” and (last 4 of it =”-500” or last 4 of it = “-501”)) of property “SID” of it) of WMI)
A: name=Administrator; Renamed=False; SID=S-1-5-21-1292428093-113007714-839522115-500; disabled=False
A: name=Guest; Renamed=False; SID=S-1-5-21-1292428093-113007714-839522115-501; disabled=False
Tweak it to match your display preferences and enjoy!
Cheers,
Brolly