Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - See who is logged in on a remote computer.

Reply
 
Old 08-06-2008   #1 (permalink)
Pedro


 
 

See who is logged in on a remote computer.

I'm trying to put together a script to see who is logged in on a remote
computer on my domain. Below is a sample of what I've found, but it only
works on certain computers, not all of them. Does .NET have to be installed
on these machines for this to work?


<code>
#whologon.ps1
$a = Read-Host "Enter Machine Name"
$strComputer = "$a"
$Var = GWMI -Computer $strComputer -CL Win32_ComputerSystem
"Machine Name: " + $Var.Name + " User Name: " + $Var.UserName
</code>


The below works for all machines, why doesn't the above?

<code>
$a= Read-Host "Enter Machine Name"
$compy = $a
$server="$compy"
$process=[System.Diagnostics.Process]
$process::GetProcesses($server)
</code>

My System SpecsSystem Spec
Old 08-06-2008   #2 (permalink)
Shay Levy [MVP]


 
 

Re: See who is logged in on a remote computer.

Hello Pedro,


Try PsLoggedOn.exe from SysInternals: http://technet.microsoft.com/en-us/s.../bb897545.aspx


PS > psloggedon -l -x \\computerName

Users logged on locally:
NT AUTHORITY\LOCAL SERVICE
NT AUTHORITY\NETWORK SERVICE
DOMAIN\ShayL
NT AUTHORITY\SYSTEM




---
Shay Levy
Windows PowerShell
http://blogs.microsoft.co.il/blogs/ScriptFanatic

P> I'm trying to put together a script to see who is logged in on a
P> remote computer on my domain. Below is a sample of what I've found,
P> but it only works on certain computers, not all of them. Does .NET
P> have to be installed on these machines for this to work?
P>
P> <code>
P> #whologon.ps1
P> $a = Read-Host "Enter Machine Name"
P> $strComputer = "$a"
P> $Var = GWMI -Computer $strComputer -CL Win32_ComputerSystem
P> "Machine Name: " + $Var.Name + " User Name: " + $Var.UserName
P> </code>
P> The below works for all machines, why doesn't the above?
P>
P> <code>
P> $a= Read-Host "Enter Machine Name"
P> $compy = $a
P> $server="$compy"
P> $process=[System.Diagnostics.Process]
P> $process::GetProcesses($server)
P> </code>


My System SpecsSystem Spec
Old 08-08-2008   #3 (permalink)
Jack Wishbone


 
 

Re: See who is logged in on a remote computer.

You could query the security event logs on your DCs for Event ID: 680:

through DCOM with a "System.Diagnostics.EventLog" object

-or-

via WMI via Win32_NTLogEvent

-JW

"Pedro" <Pedro@xxxxxx> wrote in message
news:5A846218-FA46-4B5B-90F3-66B211B886A1@xxxxxx
Quote:

> I'm trying to put together a script to see who is logged in on a remote
> computer on my domain. Below is a sample of what I've found, but it only
> works on certain computers, not all of them. Does .NET have to be
> installed
> on these machines for this to work?
>
>
> <code>
> #whologon.ps1
> $a = Read-Host "Enter Machine Name"
> $strComputer = "$a"
> $Var = GWMI -Computer $strComputer -CL Win32_ComputerSystem
> "Machine Name: " + $Var.Name + " User Name: " + $Var.UserName
> </code>
>
>
> The below works for all machines, why doesn't the above?
>
> <code>
> $a= Read-Host "Enter Machine Name"
> $compy = $a
> $server="$compy"
> $process=[System.Diagnostics.Process]
> $process::GetProcesses($server)
> </code>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Restrict logged on user access to resources on computer Vista General
computer deletes files whenever it is logged off or shut down Vista performance & maintenance
checked for logged on user on remote machine + remote reboot PowerShell
Remote Desktop Crashes Vista machin logged into Vista General
Others are logged on to this computer Warning Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46