Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

How do I find a user name who logged on to the workstation?

How do I find a user name who is logged on to the workstationwith knowen Ip address and a computer name
0
PeterGbiorczyk
Asked:
PeterGbiorczyk
2 Solutions
 
oBdACommented:
Try Sysinternals PsLoggedOn (http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx):
psloggedon \\ComputerName
0
 
Chris DentPowerShell DeveloperCommented:

There are a few different ways.

On the simple level you can connect to the Administrative share (C$), then sort the contents of "Documents and Settings" by date modified.

Or you can use WMI and get the value of UserName from Win32_ComputerSystem. VbScript and PowerShell examples of that below.

Chris
' VbScript example
strComputer = "The IP"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery("SELECT UserName FROM Win32_ComputerSystem")
For Each objItem in colItems
  WScript.Echo objItem.UserName
Next
 
# PowerShell example
(Get-WMIObject Win32_ComputerSystem -Computer "The IP").UserName

Open in new window

0

Featured Post

Industry Leaders: 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!

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