PowerShell – Get Current User of Remote PC


Did you ever need to know who is currently logged on on a Remote PC? Today I wrote a little Script which can answer this question.

function Get-CurrentLoggedOnUser
{
Param([parameter(Mandatory=$true)][alias("Computer")]$ComputerName)

#Get Computer Information from specified Computer
$ComputerInfo = Get-WmiObject Win32_ComputerSystem -Computer $ComputerName
$ComputerInfo.UserName
}

When you run this function it will return a result like this:

intranet\theezitguy

Now you know who is logged on on a Remote PC. Simple and easy. As always you can download my Script from here.

Sources:

http://www.computerperformance.co.uk/powershell/powershell_wmi_file.htm

Advertisements
Tagged

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: