I need to know what computer a user is login in on

zetsway

Senior member
Nov 8, 2007
721
0
76
Is there any software out there that will help me to do this? Or is there a script I can write that will capture the user computer name on logon and give me that information?
 

Jamsan

Senior member
Sep 21, 2003
795
0
76
I tie the following script to logon using group policy in an AD environment. A separate file is created for each user and contains the computer's name they logged on to, the username, date and time.

echo Login From: %COMPUTERNAME%, User Name: %USERNAME%, %DATE:~-10,2%/%DATE:~-7,2%/%DATE:~-4,4%, %TIME% >> \\fileserver\share\%username%.txt
 

Jeff7181

Lifer
Aug 21, 2002
18,368
11
81
Wouldn't auditing successful logins tell you all that information without the need to run a custom script?
 

zetsway

Senior member
Nov 8, 2007
721
0
76
Originally posted by: Jamsan
I tie the following script to logon using group policy in an AD environment. A separate file is created for each user and contains the computer's name they logged on to, the username, date and time.

echo Login From: %COMPUTERNAME%, User Name: %USERNAME%, %DATE:~-10,2%/%DATE:~-7,2%/%DATE:~-4,4%, %TIME% >> \\fileserver\share\%username%.txt

that's pretty neat. I've never thought about it.

Thanks I going to try it out right now.
 

zetsway

Senior member
Nov 8, 2007
721
0
76
Originally posted by: Jeff7181
Wouldn't auditing successful logins tell you all that information without the need to run a custom script?

What do you mean?
 

Jeff7181

Lifer
Aug 21, 2002
18,368
11
81
Originally posted by: zetsway
Originally posted by: Jeff7181
Wouldn't auditing successful logins tell you all that information without the need to run a custom script?

What do you mean?

Link... that particular setting may not do exactly what you want... but you can see there are other options there that may.
 

zetsway

Senior member
Nov 8, 2007
721
0
76
Originally posted by: Jeff7181
Originally posted by: zetsway
Originally posted by: Jeff7181
Wouldn't auditing successful logins tell you all that information without the need to run a custom script?

What do you mean?

Link... that particular setting may not do exactly what you want... but you can see there are other options there that may.

Thanks I'll try this out in a few. I really appreciate it. :)
 

zetsway

Senior member
Nov 8, 2007
721
0
76
Originally posted by: Jamsan
I tie the following script to logon using group policy in an AD environment. A separate file is created for each user and contains the computer's name they logged on to, the username, date and time.

echo Login From: %COMPUTERNAME%, User Name: %USERNAME%, %DATE:~-10,2%/%DATE:~-7,2%/%DATE:~-4,4%, %TIME% >> \\fileserver\share\%username%.txt

this doesn't work :(
 

Jamsan

Senior member
Sep 21, 2003
795
0
76
I use it in production at work, so I know it works :p

How exactly do you have it configured? Do you have it tied through group policy for the correct OU as a logon script? Did you add the code to your already existing logon scripts? Did you properly modify the \\fileserver\share\ portion to a valid share in your current environment?
 

zetsway

Senior member
Nov 8, 2007
721
0
76
Originally posted by: Jamsan
I use it in production at work, so I know it works :p

How exactly do you have it configured? Do you have it tied through group policy for the correct OU as a logon script? Did you add the code to your already existing logon scripts? Did you properly modify the \\fileserver\share\ portion to a valid share in your current environment?

I added it in GP under logon scripts. I have the apporiate permissions set for file. I don't know it weird, I've tried multiple times and it doesn't work. I must be doing something wrong.
I said it has a .bat file

Anyway, so I was searching all over the internet and I found some code. I made a few changes but this seems to work just fine. However, I have to get it to append to the next line in the file.

See below....... VB Script file
on error resume next
'wscript.echo "Logging....."
const ForAppending = 8
dim net,fso,f
Set net = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
set wshell = wscript.createobject("wscript.shell")
Set WshSysEnv = WShell.Environment("SYSTEM")


'uname = net.username
uname = wshell.ExpandEnvironmentStrings("%USERNAME%")
'wscript.echo "! " & uname

datetemp = date
ttemp = time
cname = net.ComputerName
'cname = wshell.ExpandEnvironmentStrings("%COMPUTERNAME%")

'path1=list of ppl who have used computer cname
'path2=list of computers person uname has used
'path3=list of shortcuts install in startmenu

path1 = "\\fileserver\Share\Logon Scripts\UsersPC\computer\logs\" & lcase(cname) & ".txt"
path2 = "\\ifileserver\Share\Logon Scripts\UsersPC\users\logs\" & lcase(uname) & ".txt"
path3 = "\\fileserver\Share\Logon Scripts\UsersPC\" & lcase(cname) & ".txt"

If (fso.FileExists(path3)) Then fso.DeleteFile(path3) end if

Set f1 = fso_OpenTextFile(path1, ForAppending, True)
Set f2 = fso_OpenTextFile(path2, ForAppending, True)

f1.writeline " was used by " & lcase(uname) & " on " & datetemp & " at " & ttemp
f2.writeline "used computer " & lcase(cname) & " on " & datetemp & " at " & ttemp

if WshSysEnv("OS")="" then
WShell.Run "%comspec% /c dir " & chr(34) & "c:\windows\start menu\*.lnk" & chr(34) & " /a-d /b /s >> " & path3 ,0,true
end if


f1.close
f2.close
'wscript.echo "Logging Done"