Notification

Icon
Error

Multiple Computers per User

Posted: Wednesday, July 29, 2020 7:13:28 PM(UTC)
brodiemac-too

brodiemac-too

Member Original PosterPosts: 48
0
Like
I our environment, everyone has one computer. However, there are some people who have been issued two. In this case, both computers are listed as Windows Computers Logged Into under the user profile. How can I generate a report that lists users with more than one computer and list the computers?
RC62N
#1RC62N Member Posts: 562  
posted: 7/29/2020 7:58:09 PM(UTC)
Give this a try:
Code:
Select Top 1000000
  tblAssets.Userdomain,
  tblAssets.Username,
  tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypename,
  tsysAssetTypes.AssetTypeIcon10 As icon,
  tblAssets.IPAddress,
  tblAssets.Lastseen,
  tblAssets.Lasttried
From
  tblAssets
  Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
  Inner Join tblComputerSystem ON tblComputerSystem.AssetID = tblAssets.AssetID
  Inner Join (SELECT
                tblAssets.Userdomain,
                tblAssets.Username,
                Count(*) AS UserCount
              FROM
                tblAssets
                Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
				Inner Join tblComputerSystem ON tblComputerSystem.AssetID = tblAssets.AssetID
              WHERE
                tblAssetCustom.State = 1
				AND tblComputerSystem.DomainRole < 2  -- non-servers
                AND tblAssets.Userdomain IS NOT NULL
                AND tblAssets.Username IS NOT NULL
              GROUP BY
                tblAssets.Userdomain,
                tblAssets.Username) AS UserCount ON UserCount.UserDomain=tblAssets.UserDomain
                                                    AND UserCount.UserName=tblAssets.UserName
                                                    AND UserCount.UserCount > 1  -- only those logged into more than 1 machine
Where
  tblAssetCustom.State = 1
  And tblComputerSystem.DomainRole < 2  -- non-servers
Order By
  tblAssets.Userdomain,
  tblAssets.Username,
  tblAssets.AssetName

The sub-SELECT makes a list of domain/users last logged on to active non-servers.

The JOIN limits the list to only those logged on to more than one machine, and the fact that it's an INNER join limits the main selection to only members of that list.
brodiemac-too
#2brodiemac-too Member Original PosterPosts: 48  
posted: 7/30/2020 12:43:38 PM(UTC)
Spot on, thank you!

Originally Posted by: RC62N Go to Quoted Post
Give this a try:
Code:
Select Top 1000000
  tblAssets.Userdomain,
  tblAssets.Username,
  tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypename,
  tsysAssetTypes.AssetTypeIcon10 As icon,
  tblAssets.IPAddress,
  tblAssets.Lastseen,
  tblAssets.Lasttried
From
  tblAssets
  Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
  Inner Join tblComputerSystem ON tblComputerSystem.AssetID = tblAssets.AssetID
  Inner Join (SELECT
                tblAssets.Userdomain,
                tblAssets.Username,
                Count(*) AS UserCount
              FROM
                tblAssets
                Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
				Inner Join tblComputerSystem ON tblComputerSystem.AssetID = tblAssets.AssetID
              WHERE
                tblAssetCustom.State = 1
				AND tblComputerSystem.DomainRole < 2  -- non-servers
                AND tblAssets.Userdomain IS NOT NULL
                AND tblAssets.Username IS NOT NULL
              GROUP BY
                tblAssets.Userdomain,
                tblAssets.Username) AS UserCount ON UserCount.UserDomain=tblAssets.UserDomain
                                                    AND UserCount.UserName=tblAssets.UserName
                                                    AND UserCount.UserCount > 1  -- only those logged into more than 1 machine
Where
  tblAssetCustom.State = 1
  And tblComputerSystem.DomainRole < 2  -- non-servers
Order By
  tblAssets.Userdomain,
  tblAssets.Username,
  tblAssets.AssetName

The sub-SELECT makes a list of domain/users last logged on to active non-servers.

The JOIN limits the list to only those logged on to more than one machine, and the fact that it's an INNER join limits the main selection to only members of that list.


Active Discussions

Installer Stop Print Spooler Service
by  Esben.D   Go to last post Go to first unread
Last post: 7/16/2021 2:43:23 PM(UTC)
Installer Java Uninstall Deployment
by  Rodrigo Varela   Go to last post Go to first unread
Last post: 7/1/2021 9:49:00 AM(UTC)
Installer Java Uninstall Deploy
by  Rodrigo Varela  
Go to last post Go to first unread
Last post: 7/1/2021 9:47:26 AM(UTC)
Installer Installing Windows 10 on Win 7?
by  user9482840   Go to last post Go to first unread
Last post: 6/24/2021 1:32:05 AM(UTC)
Installer Uninstall KB5000802
by  hirogen  
Go to last post Go to first unread
Last post: 6/8/2021 2:49:19 PM(UTC)
Installer Freezerworks 2021 Client
by  mzipperer   Go to last post Go to first unread
Last post: 6/2/2021 11:59:05 PM(UTC)
Installer Install .Net Framework 4.7.2
by  John B Fairbrother  
Go to last post Go to first unread
Last post: 5/6/2021 4:58:23 PM(UTC)