Action 1 (default)
Action Link Click
here to deploy this action.
Script Type
BigFix Action Script
regset "[HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats]" "LoggedIn"="{exists logged on users whose (active of it)}"
regset "[HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats]" "LastLoggedInUser"="{tuple string item 0 of concatenation ", " of items 0 of ((item 0 of item 1 of it, item 1 of item 0 of it) of ((it,((preceding texts of firsts "%22" of following texts of firsts "Name=%22" of it, preceding texts of firsts "%22" of following texts of firsts ".LogonId=%22" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of (string values of selects "* from Win32_LoggedOnUser" of wmi)) & "|")))) of ((preceding texts of firsts "|" of it, following texts of firsts "|" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of ((if (it as string contains "LogonId") then (string values of it) else if (it as string contains "StartTime") then (time values of it as string) else "") of (selects "StartTime, LogonId from Win32_LogonSession where (LogonType=2 OR LogonType=10)" of wmi))) & "|")))) whose (item 0 of item 0 of it = item 1 of item 1 of it)) whose (item 1 of it = (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string))}"
regset "[HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats]" "LastTime"="{maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi}"
regset "[HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats]" "LogonHistory"="{if (exists logged on users whose (active of it)) then (if (exists values "LogonHistory" of keys "HKLM\Software\BigFix\EnterpriseClient\userstats" of registry) then ((if (value "LogonHistory" of keys "HKLM\Software\BigFix\EnterpriseClient\userstats" of registry as string contains (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string)) then ("") else ("::" & (tuple string item 0 of concatenation ", " of items 0 of ((item 0 of item 1 of it, item 1 of item 0 of it) of ((it,((preceding texts of firsts "%22" of following texts of firsts "Name=%22" of it, preceding texts of firsts "%22" of following texts of firsts ".LogonId=%22" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of (string values of selects "* from Win32_LoggedOnUser" of wmi)) & "|")))) of ((preceding texts of firsts "|" of it, following texts of firsts "|" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of ((if (it as string contains "LogonId") then (string values of it) else if (it as string contains "StartTime") then (time values of it as string) else "") of (selects "StartTime, LogonId from Win32_LogonSession where (LogonType=2 OR LogonType=10)" of wmi))) & "|")))) whose (item 0 of item 0 of it = item 1 of item 1 of it)) whose (item 1 of it = (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string))) & ";;" & (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string))) & (if (not exists value "LogonHistory" of keys "HKLM\Software\BigFix\EnterpriseClient\userstats" of registry) then "" else (concatenation of (("::" & item 0 of it & ";;" & item 1 of it) of (((items 0 of it, items 1 whose (it as time > (now - 7 * day)) of it) of ((preceding texts of firsts ";;" of it, following texts of firsts ";;" of it) of (substrings separated by "::" whose (it != "") of (value "LogonHistory" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string))))))))) else ("::" & (tuple string item 0 of concatenation ", " of items 0 of ((item 0 of item 1 of it, item 1 of item 0 of it) of ((it,((preceding texts of firsts "%22" of following texts of firsts "Name=%22" of it, preceding texts of firsts "%22" of following texts of firsts ".LogonId=%22" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of (string values of selects "* from Win32_LoggedOnUser" of wmi)) & "|")))) of ((preceding texts of firsts "|" of it, following texts of firsts "|" of it) of ((following texts whose (number of substrings "|" of it is 1) of substrings "|" of preceding texts whose (number of substrings "|" of it mod 2 is 0) of substrings "|" of it) of ("|" & (concatenation "|" of ((if (it as string contains "LogonId") then (string values of it) else if (it as string contains "StartTime") then (time values of it as string) else "") of (selects "StartTime, LogonId from Win32_LogonSession where (LogonType=2 OR LogonType=10)" of wmi))) & "|")))) whose (item 0 of item 0 of it = item 1 of item 1 of it)) whose (item 1 of it = (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string))) & ";;" & (maximum of time values of selects "starttime from win32_logonsession where (LogonType=2 OR LogonType=10)" of wmi as string))) else (value "LogonHistory" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string)}"
regset "[HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats]" "PrimaryUser"="{if (exists (key "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" whose (exists value "LogonHistory" of it) of registry)) then (item 0 of ((items 0 whose ((concatenation of (unique values whose ((multiplicity of it = (maximum of multiplicities of unique values of preceding texts of firsts ";;" of substrings separated by "::" of (value "LogonHistory" of key "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string)))) of preceding texts of firsts ";;" of substrings separated by "::" of (value "LogonHistory" of key "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string)) as string) contains it) of it, items 1 whose (it as time = maximum of (((following texts of firsts ";;" of it) of (substrings separated by "::" whose (it != "") of (value "LogonHistory" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string))) as time)) of it) of (((preceding texts of firsts ";;" of it, following texts of firsts ";;" of it) of (substrings separated by "::" whose (it != "") of (value "LogonHistory" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\userstats" of registry as string)))))) else "N/A"}"
Success Criteria
This action will be considered successful when the applicability relevance evaluates to false.