Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
2000sITGinger
Engaged Sweeper II

Is there a way to pull primary user information from either Intune or AD? From what I've gathered reading on the forums, it is not yet possible? Just want to confirm this.

 

We want to know who the primary user is on-top of knowing the last-login.

4 REPLIES 4
sqldba01
Engaged Sweeper III

This can be run in SSMS but not Lansweeper reporting because of the temp table. It will give you the most frequent logon over 60 days. We later join it with asset info to pull expiring warranty by user and department for budgeting purposes.   

-- First query: Get the most frequent logon user for each AssetID

WITH LogonCounts

AS (SELECT AssetID,

username,

COUNT(*) AS logon_count,

ROW_NUMBER() OVER (PARTITION BY AssetID ORDER BY COUNT(*) DESC) AS rn

FROM tblCPlogoninfo

WHERE logontime >= DATEADD(DAY, -60, GETDATE())

GROUP BY AssetID,

username)

SELECT AssetID,

username AS PrimaryLogin,

logon_count

INTO #tempLogonInfo

FROM LogonCounts

WHERE rn = 1

ORDER BY AssetID;

sqldba01
Engaged Sweeper III

And you could add email if desired from 'tblADUsers'.

FrankSc
Lansweeper Tech Support
Lansweeper Tech Support

Dear, 
With an Intune scan, we scan the UPN and email address that is returned from Azure on the device.
If that matches with the email Address of a scanned AD account, this account will be also linked in the Asset page.
The UPN is the only information we get. Intune does not return if that is the primary user specifically.

sqldba01
Engaged Sweeper III

Lansweeper asset views reflect last logon as well which may not be the primary user. The ' tblCPlogoninfo' table has over six months of login history. The query above considers the last 60 days of use. The data in Lansweeper can come from a number of scanning targets, including the Intune Endpoint Manager target. I entered an enhancement request a long while ago to calculate and reflect primary user in a field and have it be reportable.