Dan
Dan

Reputation: 31

Get running processes for remote computers with username

I need to monitor when a process stops running for each user on remote machines.

I can get the processes and usernames for processes running on a machine:

Get-Process -IncludeUserName

And I can get the processes running on remote machines (without the usernames):

Get-Process -ComputerName Test-PC

But I can't join the two together! For example this does not work:

Get-Process -ComputerName Test-PC -IncludeUserName

How can I do this?

Upvotes: 0

Views: 4655

Answers (1)

Jawad
Jawad

Reputation: 11364

Following is an example of running a script / command on a remote computer,

$processes = Invoke-Command -ComputerName Test-PC -scriptBlock { Get-Process -IncludeUserName }

This will give you all the processes with username from the remote computer. If you need to provide different credentials, you can use the -Credential switch.

Documentation on Invoke-Command - You should read up on this to get details on other switches.

Upvotes: 1

Related Questions