Skip to content

Instantly share code, notes, and snippets.

@marcolussetti
Created November 22, 2024 22:23
Show Gist options
  • Save marcolussetti/7aac9a8b564883e2e60c5ef11413c379 to your computer and use it in GitHub Desktop.
Save marcolussetti/7aac9a8b564883e2e60c5ef11413c379 to your computer and use it in GitHub Desktop.
Get users <-> machine login history in MECM 2403
SELECT DISTINCT
UPPER(COALESCE(SCU.SystemConsoleUser0, UMR.UniqueUserName)) as Username,
SYS.Name0 as Machine,
COALESCE(
SCU.LastConsoleUse0,
UMR.CreationTime
) as Time_Last_Logged_On_Machine
FROM
v_R_System SYS
LEFT JOIN v_GS_SYSTEM_CONSOLE_USER SCU ON
SYS.ResourceID = SCU.ResourceID
LEFT JOIN v_UserMachineRelation UMR ON
SYS.ResourceID = UMR.MachineResourceID
WHERE
(
(SCU.SystemConsoleUser0 IS NOT NULL AND SCU.SystemConsoleUser0 != '')
OR
(UMR.UniqueUserName IS NOT NULL AND UMR.UniqueUserName != '')
)
AND (
SCU.LastConsoleUse0 IS NOT NULL
OR UMR.CreationTime IS NOT NULL
)
AND (
UMR.RelationActive = 1
OR UMR.RelationActive IS NULL
)
ORDER BY
Username,
Machine,
Time_Last_Logged_On_Machine DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment