Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Users logged in to computers

I need to query a list of computers and retrieve users that have logged in to each computer.
for instance:
computerA =User1 logged in
ComputerB=User20 logged in

it will be nice if the script can give me for instance:
computerA= user1 ,user7,user3 have logged into at separate date and time..

Thanks
0
jskfan
Asked:
jskfan
3 Solutions
 
JoeIronsmithCommented:
Hi,

You can add this into your user's logon script:

@echo off
echo %date% %time% Logon %UserName% %ComputerName% >> \\MyServer\MyShare\LogTimes.txt

Then you can open it via excel (open a new file / Data / From text) and filter and sort it based on what information you need, e.g. username, computer name, etc.

Cheers,
Joe
0
 
SreRajCommented:
Hi,

You could try the following PowerShell script from Technet Script Gallery.

http://gallery.technet.microsoft.com/scriptcenter/d46b1f3b-36a4-4a56-951b-e37815a2df0c
0
 
Krzysztof PytkoActive Directory EngineerCommented:
Try to do that with free SysInternals tool called PsLoggedOn
http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx

This is really easy in use tool which allows for scripting

Regards,
Krzysztof
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
jskfanAuthor Commented:
PsLoggedOn tool can be used to find current logged on user to which computer.

I need the last user logged on
0
 
jskfanAuthor Commented:
this is right link:

http://www.intelliadmin.com/index.php/2012/06/find-out-who-logged-on-to-a-computer/


Set objWMIService = GetObject("winmgmts:\\Remotecomputername\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")

For Each objItem in colItems
   
   Wscript.Echo objItem.Name
   
 Next
0
 
jskfanAuthor Commented:
Thank you Guys...The script I posted did the work
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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