Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Track what machines an user is logged on to

Status
Not open for further replies.

zodiaczz

Technical User
Feb 19, 2005
113
CA
Is there a way via tool or script to search the domain and see how many machines a particular user is logged on to and what those machine names are?

Thanks all
 
Hi Zodiaczz,

This should hopefully solve your problem:


You have to install it on each client computer, but that shouldnt be a problem. Just do it through AD, then you can run the .adm file and get all the information you need.

Hope this helps,

Andy

Like cellotape, im on a roll and take drugs not candy from strangers...
 
If your goal is to simply track the information then I would suggest something via a login script. Somthing simple like this;

Code:
'==========================================================================
'
' NAME: RecordLoginLocations.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYRIGHT (c) 2006 All Rights Reserved
' DATE  : 6/24/2006
'
' COMMENT: 
'
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("WScript.Network")
'Grab the user name
UserString = WSHNetwork.UserName
'Grab the computer name 
strComputer = WSHNetwork.ComputerName
'Now log the login to a file
'Set objLogFile = objFSO.OpenTextFile("\\sserver\share\logrecord.txt", _ 
Set objLogFile = objFSO.OpenTextFile("C:\logrecord.txt", _ 
    ForAppending, True)
    objLogFile.Write UserString & " logged onto :" & strComputer & " " & Now() 
    objLogFile.writeline
	objLogFile.Close
WScript.Quit

If on the other hand you need to determine who is logged in on specific computers then a script like this will help

Code:
'==========================================================================
'
' NAME: WhoIsLoggedInThereListVer.vbs 
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYRIGHT (c) 2005 All Rights Reserved
' DATE  : 12/14/2005
'
' COMMENT: This script and many more are available in the Admin Script Pack
'          by The Spider's Parlor.  [URL unfurl="true"]http://www.TheSpidersParlor.com/vbscript[/URL]
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
For Each strComputer In RemotePC
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem in colItems
	    Report = Report &  "UserName: " & objItem.UserName & " is logged in at computer " & strComputer & vbCrLf
	Next
Next

Set ts = oFSO.CreateTextFile ("logreport.txt", ForWriting)
ts.write report

The above scritp requires you provide a WSLIST.TXT file of what workstation names to check. You can automatically generate that list with the script in my FAQ faq329-4871.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Forgot to uncomment out the log location line for a network in my posting. Remove the line for creating the log on the C drive and uncomment out the line above it.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Thanks I will check it out

Appreciate it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top