simpat1zq
asked on
Find name of computer a user last logged onto
Is there an active directory(or sms) script that will tell me the name of the computer that a user logged onto last, or is currently logged into?
thx.
thx.
This might be of help to you: http://www.sysinternals.com/Utilities/PsLoggedOn.html
SMS will also give you the ability to find a user.
Also you can use the Resource Kit's 'cconnect' tool. Look for it in the 'apps' directory of your Resource Kit CD. There's a Word doc that explains it. This takes a little doing to set up
Also you can use the Resource Kit's 'cconnect' tool. Look for it in the 'apps' directory of your Resource Kit CD. There's a Word doc that explains it. This takes a little doing to set up
ASKER
That tool would take about an hour to run. I need this to avoid having to ask the user to look up the computer name.
ASKER
Does SMS have a resource kit? Can I download the cconnect tool?
ASKER
OK, I see that that tool is used in server 2000, but I guess it's not available in 2003. Can I use that tool on a 2003 domain just to see what computer the user is logged into?
Couple of possibilites:
If you have WINS still then the username will be registered in WINS against the IP address - check a query out in the WINS admin tool.
Once you have an Ip then NBTSTAT -A ipaddress will show you the names registered on that computer at the moment which will include the username, domain name, computer name etc.
Doesn't help once users are already logged in but good for logging, I actually run a script from login script which goes away and create a directory for each day, os, user, and computer appending a text file for each -- it goes something like this and just needs a hidden share that users have write rights to. This is an Auto-It file that compiles to an EXE that can be run from a login script but not too difficult as a batch file either:
;
; AutoIt Version: 2.x
; Language: English
; Platform: Win9x/NT
; Author: Steve Knight (sk@dragon-it.co.uk)
; Date: 14-2-2002
RegRead,CompName,REG_SZ,HK EY_LOCAL_M ACHINE,Sys tem\\Curre ntControlS et\\contro l\\Compute rName\\Com puterName, ComputerNa me
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ USER\\%use rname%.txt
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ PC\\%compn ame%.txt
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ PC\\%A_OSV ERSION%.tx t
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ PC\\%A_YEA R%-%A_MON% .txt
You end up with a file for each user, computer, month, and OS saying when they have logged on and from what computer and OS.
If you have WINS still then the username will be registered in WINS against the IP address - check a query out in the WINS admin tool.
Once you have an Ip then NBTSTAT -A ipaddress will show you the names registered on that computer at the moment which will include the username, domain name, computer name etc.
Doesn't help once users are already logged in but good for logging, I actually run a script from login script which goes away and create a directory for each day, os, user, and computer appending a text file for each -- it goes something like this and just needs a hidden share that users have write rights to. This is an Auto-It file that compiles to an EXE that can be run from a login script but not too difficult as a batch file either:
;
; AutoIt Version: 2.x
; Language: English
; Platform: Win9x/NT
; Author: Steve Knight (sk@dragon-it.co.uk)
; Date: 14-2-2002
RegRead,CompName,REG_SZ,HK
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
You end up with a file for each user, computer, month, and OS saying when they have logged on and from what computer and OS.
Yes you can use that tool in 2003 server as well
This is the MS KB on it:
http://support.microsoft.com/Default.aspx?kbid=237282
But I have found a newer tool from MS that takes CCconects place:
Look for a tool called LimitLogon. It is the new Microsoft replacement tool for cconnect to limit concurrent connections/logons.
http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/limitlogin.exe
Another choice:
1) The UserLock product in the link below is an option:
http://www.softwareshelf.com/products/display.asp?p=42
This is the MS KB on it:
http://support.microsoft.com/Default.aspx?kbid=237282
But I have found a newer tool from MS that takes CCconects place:
Look for a tool called LimitLogon. It is the new Microsoft replacement tool for cconnect to limit concurrent connections/logons.
http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/limitlogin.exe
Another choice:
1) The UserLock product in the link below is an option:
http://www.softwareshelf.com/products/display.asp?p=42
Here's some more info on Limit Login: http://www.microsoft.com/technet/technetmag/issues/2005/05/UtilitySpotlight/default.aspx
Last two should missed a bit in the cut & paste:
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ OS\\%A_OSV ERSION%.tx t
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\ DATE\\%A_Y EAR%-%A_MO N%.txt
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\
ACK!! never mind my last 2 post. It went into the wrong Question.. and has to do with limit logins...Sorry
if the user has a drive mapped or network filesystem open to some server, you can look at the 'shares' control on the server and see the username and the computer name those resources are access from/by.
Cheers.
Cheers.
ASKER
The thing is that I really want to get the name via a script. I just thought it might be possible using sms somehow to get it. I want it from a script so that I can merge it with another script which needs the computer name a user is connected to.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
nice, i think I'll try that one.
ASKER
Yup, that's the one I'm going with. So far i've got a vbscript that creates a file on the share named %username% with %comptername% in it. Now I can use my other scripts to read from those files.
In case any of you were wondering, I'm doing this so that I can connect to someone's computer using SMS remote tools, simply by entering the user's name. If anyone needs these scripts(when I'm done) just ask, I'll post them here.
Thank you.
In case any of you were wondering, I'm doing this so that I can connect to someone's computer using SMS remote tools, simply by entering the user's name. If anyone needs these scripts(when I'm done) just ask, I'll post them here.
Thank you.
Nice one, thanks for the points :-)
When you append to the file (use >> if you are using an echo redirection like above) you end up with a nice little audit history too... and you can just read the last line with your script to get the last computer ... or even get clever and offer a list of their last couple by showing the last 5 lines of the file in a dialog for the user to choose before parsing the computername out...
I've found SMS remote a bit of a pain -, at one place it would not work from the commandline with a netbios computername so I wrote scripts to resolve those to IP address and pass that. Have you tried just running remote.exe with a paramater 3 then the username... vaguely possible it might work?
Steve
When you append to the file (use >> if you are using an echo redirection like above) you end up with a nice little audit history too... and you can just read the last line with your script to get the last computer ... or even get clever and offer a list of their last couple by showing the last 5 lines of the file in a dialog for the user to choose before parsing the computername out...
I've found SMS remote a bit of a pain -, at one place it would not work from the commandline with a netbios computername so I wrote scripts to resolve those to IP address and pass that. Have you tried just running remote.exe with a paramater 3 then the username... vaguely possible it might work?
Steve
ASKER
Right now I've got an SMS remote tools script that asks for a computername, and then it resolves the IP, and connects using the IP. I found that script off of google, and it just works, no modification necessary. What I'm going to do is modify that script so it makes use of this username thing.
What you said got me thinking about maybe making a logoff script that removes the computer name when they logoff. That way the file would only have a list of computers that they are logged into. But that list might get messy to do to computer crashes and stuff. Maybe I could put in a time/date after the computer name, and run clean up using the login script.
I probably won't do that since most people only log into 1 computer at a time. But I doubt it would be incredibly hard to do.
What you said got me thinking about maybe making a logoff script that removes the computer name when they logoff. That way the file would only have a list of computers that they are logged into. But that list might get messy to do to computer crashes and stuff. Maybe I could put in a time/date after the computer name, and run clean up using the login script.
I probably won't do that since most people only log into 1 computer at a time. But I doubt it would be incredibly hard to do.
ASKER
And I just checked the "remote 3" thing. The 3 just means that it will use the netbios name of the computer. The script I had found finds the IP on it's own and uses "remote 2". But neither can use the username.
Fair enough, I've always resolved the IP and used "remote 2" too... post your script here when done if poss.
Steve
Steve
ASKER
I will. If I don't this week(let's say by wednesday), could you just post here again, so I get an email reminding me to. I tend to forget stuff like this.
I stumbled on this post looking for a different answer, however, this sounds like something that would help me out a bit..I've all but given up on SMS.
I would love to take a look at those scripts if you wouldn't mind...
I would love to take a look at those scripts if you wouldn't mind...
ASKER
I'm sorry. I did all that at my last job. I'm 99% sure that the work I did on this is gone. I left when I was just finishing this thing up, and never got it done. Didn't take it with me either, even though I probably should have.
much easier wa .. if you are using domain ofcourse is:
filter the security log on the DC for the user name ;)
enjoy
filter the security log on the DC for the user name ;)
enjoy
Please contact me on email address in profile, or post a new related Q and let me know the Q number and will have a dig around, pretty sure I've got these old scripts still, and in any case can soon come up with some modern alternatives that work better,
Thanks dragon for the offer ... I appreciate it very much .. I just posted a new solution as i wehere digging for the same problem. I am a consultant myself and i would behappy to exchange solutions or solve them any time.... .