PowerShell script to get the user logged into a computer using a system account.

Get-WmiObject Win32_Process -f 'Name="explorer.exe"'  |%  getowner  |% user
$sessionId = (Get-WmiObject Win32_Process -Filter 'Name="explorer.exe"').SessionId | Select-Object -Unique
msg.exe $sessionId "$message"

Categories: Powershell

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.