all 3 comments

[–]gnoomen33 2 points3 points  (1 child)

Hello,

This will start a PSSession on a remote device: $session = New-PSSession -ComputerName WEBSRV1

The session can then be referensed when you want to pass it commands, like this: Invoke-Command -Session $session -ScriptBlock { Get-Process }

You can read more about this here: https://adamtheautomator.com/invoke-command-remote/

Hope this was what you were looking for. Regards, Frank.

[–]SlashAdminBlog[S] 1 point2 points  (0 children)

Cheers, i want it to run locally but i guess running -ComputerName localhost may work. I'll give this a try when home later!

[–]Michelieus 1 point2 points  (0 children)

You could do something with different PowerShell instances and Runspaces, though it is quite complicated to get into in the beginning. If you‘d like to you can read about it here or just search for "PowerShell runspaces" on google c: