Link to home
Start Free TrialLog in
Avatar of hb21l6
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
ASKER CERTIFIED SOLUTION
Avatar of _Maddog_
_Maddog_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hb21l6
hb21l6

ASKER

nice one
 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=impersonate}!\\" & strComputer & "\root\cimv2")

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
Avatar of hb21l6

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.FileSystemObject")
Set GuyFile = myFSO.OpenTextFile("c:\yourtextfile.txt", 8, True)


Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://DC=MyDomain,DC=LOCAL' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 500
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
 


strComputer = objRecordSet.Fields("Name").Value

      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & 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
Avatar of hb21l6

ASKER

thanks for your help anyway maddog
Avatar of hb21l6

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

Is it possible from a unix/linux machine
Avatar of hb21l6

ASKER

WMI scripts are native to windows machines Peddu, so probably not.