Solved

PowerShell: How to determine who is logged onto a remote Windows System

Posted on 2010-09-10
5
1,039 Views
Last Modified: 2012-05-10
I need some code to help me determine who is logged into a remote computer.

Specially, who is logged onto a Window 7 and/or Windows 2008 system. (Since multiple people can be logged on...)

I'm using this code now, and it pretty much shows me as logged onto a bunch of stuff... that I'm fairly certain I'm not logged into.  (So I suspect it's showing the credentials I'm using to run the script.)

$serverlist = [collections.arraylist] (@(Get-QADComputer -OSName 'Windows*Server*' | Select-Object -ExpandProperty name) | %{$_} | Sort-Object)

ForEach($Server in $serverlist)  

{Gwmi Win32_Computersystem -Comp $Server | Select Name, UserName}

I'm specifically interested to know if there is a way to determine multiple logons to one system.
0
Comment
Question by:gerhardub
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Lazarus
ID: 33649195
0
 
LVL 1

Author Comment

by:gerhardub
ID: 33649590
That doesn't appear to work, and if the function does, it's not working for me.
0
 
LVL 1

Author Comment

by:gerhardub
ID: 33649595
Is there anything that is not WMI that could be useful?
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 33649742
Not that I know of, but there might be.
0
 
LVL 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 33653924
This gives all interactive and terminal logons. Unfortunately I am not able to run it remotly using the remoting of WMI, only by the remoting of PowerShell.
Get-WmiObject -Class win32_logonsession -Filter "LogonType = 2 OR LogonType = 10"  | 

    %{ get-wmiobject -Query "Associators of {Win32_logonSession.LogonID=$($_.LogonId)} where AssocClass = Win32_LoggedOnUser Role=Dependent" }

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now