Solved

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

Posted on 2010-09-10
5
1,048 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

733 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