Logged in User Sessions on Remote Computers, if you want to query active user session or connected user session on any computer then this article is for you, here are the simple steps to achieve it.
When you want to check logged in user sessions on the remote computers without logging into each computer then we have to use a PowerShell WMI command to pull the information, windows administrators need this information before they perform any upgrades, configuration changes, and remote computer reboots. There are other ways one can also check the user sessions, here this article explains how to check the logged-in users with a script.
Here is the Powershell WMI command that pulls the logged in user information.
get-wmiobject -class Win32_computersystem | select-object username
Script for Logged in Users on Remote Computers
We need to create a text file for remote computers list that we are going to restart, here I have created a text file named as allservers.txt and saved it in location C:\temp\allservers.txt
$allservers =get-content -path "c:\temp\Allservers.txt" Foreach ($oneserver in $allservers) { Write-host "Currently the Script is running on"$oneserver get-wmiobject -class Win32_computersystem -computername $oneserver| select name,username }
The above script pulls all logged-in users on remote computers listed in the file allservers.txt and gives you information about the server’s name with respective users.
The scripts that I have written and posted as articles are tested on windows 10, windows servers 2016 operating systems. Please make sure you have the required privileges to run these script on the remote computers otherwise you may run into issues.
There are some scripts that I have published only administrators can perform or execute them on the remote computers.
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply