?
Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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 tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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…
Suggested Courses

765 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