Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-10
5
Medium Priority
?
1,059 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

604 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