Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

If Statement to Return No User Logged in on Remote Computer

$
0
0

I've been struggling with this one and need some help. The Get-WmiObject command below returns the DOMAIN\Logged_In_User on a remote computer. I would like an "If Statement" to return "No Logged User" if there are no user logged in on the remote computer.

#Provide Custom Code for events specified in PrimalForms.
$btnStatus_OnClick=
{
#TODO: Place custom script here

$sBar.Text = $txtComputer.Text + ": " + (GetStatus($txtComputer.Text))


$lblRunningAs_DATA.Text = Get-WmiObject -computername $txtComputer.Text -class win32_computersystem | select -ExpandProperty username


}


Viewing all articles
Browse latest Browse all 6937

Trending Articles