hb21l6
asked on
how to find out who is logged onto a networked PC.
windows 2003 AD domain
windows 2000 and XP desktops.
Is there anyway I can find out who is logged onto a PC on our network?
I've used NBTSCAN but thats not always reliable. infact its awful.
Does anyone know of any ADSI script or a way to get the info if i telnet to the PC's
Thanks in advance
hb
windows 2000 and XP desktops.
Is there anyway I can find out who is logged onto a PC on our network?
I've used NBTSCAN but thats not always reliable. infact its awful.
Does anyone know of any ADSI script or a way to get the info if i telnet to the PC's
Thanks in advance
hb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
here is a working script.. replace the domain name with your own and create a txt file called yourtextfile.txt on your C: drive. - only problem with it, is that its sooo slow.
DIM myfso, GuyFile
on error resume next
Set myFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set GuyFile = myFSO.OpenTextFile("c:\you rtextfile. txt", 8, True)
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connec tion")
Set objCommand = CreateObject("ADODB.Comman d")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnectio n = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://DC=MyDomain,DC=LOC AL' " _
& "Where objectClass='computer'"
objCommand.Properties("Pag e Size") = 500
objCommand.Properties("Sea rchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name" ).Value
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
GuyFile.Write ("Logged-on user: ") & objComputer.UserName & "on : " & strComputer & Vbcrlf
Next
objRecordSet.MoveNext
Loop
GuyFile.Close
DIM myfso, GuyFile
on error resume next
Set myFSO = CreateObject("Scripting.Fi
Set GuyFile = myFSO.OpenTextFile("c:\you
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connec
Set objCommand = CreateObject("ADODB.Comman
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnectio
objCommand.CommandText = _
"Select Name, Location from 'LDAP://DC=MyDomain,DC=LOC
& "Where objectClass='computer'"
objCommand.Properties("Pag
objCommand.Properties("Sea
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
GuyFile.Write ("Logged-on user: ") & objComputer.UserName & "on : " & strComputer & Vbcrlf
Next
objRecordSet.MoveNext
Loop
GuyFile.Close
ASKER
thanks for your help anyway maddog
ASKER
can even watch it real time
add this line above the guyfile.write line
wscript.echo ("Logged-on user: ") & objComputer.UserName & "on : " & strComputer & Vbcrlf
and call it from the CMD/ RUN prompt with this
cscript /nologo c:\pc2user.vbs
add this line above the guyfile.write line
wscript.echo ("Logged-on user: ") & objComputer.UserName & "on : " & strComputer & Vbcrlf
and call it from the CMD/ RUN prompt with this
cscript /nologo c:\pc2user.vbs
Is it possible from a unix/linux machine
ASKER
WMI scripts are native to windows machines Peddu, so probably not.
ASKER
thanks Maddog.. - i'll have a look and give it a go..
also found this adsi script that works.
strComputer = "tech04"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "Logged-on user: " & objComputer.UserName
Next
I'm going to create a loop to list all the PC's on the domain and wite out the users name and PC name. - once complete I'll post it for others to use...
hb