Is there any way to run a query in AD to check what PCs a user has logged into recently.
regards Mike
Is there any way to run a query in AD to check what PCs a user has logged into recently.
regards Mike
As far as I am aware, AD does not keep a log of what PC's a user logged onto, the only thing it logs is the last logon time. This item is not synchronised across domain controllers either, so can be a little unreliable if you have multiple DC's, unless you poll all DC's to find the latest time.
You could enable logging of User Logon events in the security log, export the log to CSV and use this to generate the report you are after. This also suffers from the fact that logon information is only logged by the DC that processes the request, and is not synchronised between DC's, so you would need to get this data from all of your DC's.
The PsLoggedOn script will tell you what machines users are currently logged into, if that is any use to you.
there definately is a way, we currently have it setup with a script that runs when a user logs in, it pops the pc name and logon time in the notes under the telephones tab in AD.. I will find the script and will post it up....
Regards
Not aware of any way to do this directly with AD, but if you have any kind of machine auditing system this should be fairly easy.
We use SCCM (aka SMS) for software deployment, as well as various auditing, and use this script as a quick look at where people have logged in. The full Asset Inventory service gives you much more info than this, but this is quick and easy. It's not 100% reliable (particularly if the user has logged onto multiple machines in a short time frame) but we use this script which should do what you want:
'Central Site Server
strComputer = "***"
'Central Site Code
strSiteCode = "***"
'Get userID
strUserName = InputBox ("Enter User Name")
'Set up the connection String
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)
'Get info
Set colUser = objWMIService.ExecQuery("select SMS_G_System_COMPUTER_SYSTEM.Name, SMS_R_System.LastLogonUserName from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.LastLogonUserName like '" & strUserName & "%'")
For Each objUser in colUser
LastUserName = ObjUser.SMS_R_System.LastLogonUserName
MachineName = ObjUser.SMS_G_System_COMPUTER_SYSTEM.Name
Next
'Display info
MsgBox ("Last machine that "& LastUserName &" logged onto was "& vbcrlf & MachineName)