• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9155
  • Last Modified:

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
0
hb21l6
Asked:
hb21l6
  • 5
1 Solution
 
_Maddog_Commented:
Hi hb21l6,

Consider using PsLoggedOn from SysInternals (http://www.sysinternals.com/Utilities/PsLoggedOn.html).

- Maddog
0
 
hb21l6Author Commented:
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
0
 
hb21l6Author Commented:
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hb21l6Author Commented:
thanks for your help anyway maddog
0
 
hb21l6Author Commented:
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

0
 
Peddu_bhanuCommented:
Is it possible from a unix/linux machine
0
 
hb21l6Author Commented:
WMI scripts are native to windows machines Peddu, so probably not.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now