Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Check if User is Logged In

$
0
0

I need to check if a Domain User is logged on a server.  The following can't seem to match the pattern for the user but the variables seems to be okay.   The result is always false.  I've tried using match, like, contains.

$server = "ServerA"
$ADUser = "CONTOSO\UserA"

$Loggedin = Get-WmiObject win32_computersystem -computer $server | select username

echo $server

echo $ADUser

echo $Loggedin

If ($Loggedin -match $ADUser) {write-host "yes"} ELSE {write-host "no"}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>