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

Lansweeper try to scan for software license and not working?
by  rader   Go to last post Go to first unread
Last post: Today at 4:25:37 PM(UTC)
Lansweeper LsAgent uninstalled itself (Windows 10 Enterprise)
by  LsUsers70  
Go to last post Go to first unread
Last post: Today at 3:05:37 PM(UTC)
Lansweeper Deploying PowerShell script
by  FreddieIT   Go to last post Go to first unread
Last post: Today at 10:57:34 AM(UTC)
Lansweeper Deploy package - add registry key to HKCU
by  Bginchereau  
Go to last post Go to first unread
Last post: Yesterday at 5:26:16 PM(UTC)
Lansweeper Duplicate Items
by  Tim Van Engeland   Go to last post Go to first unread
Last post: Yesterday at 2:46:32 PM(UTC)
Lansweeper Latest LsAgent version for Windows?
by  mg83  
Go to last post Go to first unread
Last post: Yesterday at 11:07:51 AM(UTC)
Lansweeper Exchange scanning
by  brama   Go to last post Go to first unread
Last post: Yesterday at 8:56:01 AM(UTC)