Computer Name and User Name

I am using SCCM 2012 R2 in my infrastructure. I would like to know how to get computer name and logged user name and last log on time. There are multiple queries and I tried to pull the report, how ever it is not consistence and the report has lot of discrepancies in connection to log on time stamp.
Is there something specifically needs to be enable for this in SCCM
Nagesh A SSCCM AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Benjamin VoglarIT ProCommented:
I just tested this one and it Works for me.

Select distinct
 v_R_System.Netbios_Name0 AS "Computer Name",
 v_GS_SYSTEM_CONSOLE_USER.SystemConsoleUser0 AS "Console User",
 v_GS_SYSTEM_CONSOLE_USER.NumberOfConsoleLogons0 AS "Console Logons",
 v_GS_SYSTEM_CONSOLE_USER.TotalUserConsoleMinutes0 AS "Total Minutes on Console",
 v_GS_SYSTEM_CONSOLE_USER.LastConsoleUse0 AS "Last Console Use"
 from v_R_System INNER JOIN
 ON v_GS_SYSTEM_CONSOLE_USER.ResourceID = v_R_System.ResourceID
 Order by v_R_System.Netbios_Name0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nagesh A SSCCM AdministratorAuthor Commented:
this requires to enable log on Audit in the security and I could able to get the details.  thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.