New-RemoteProcess

I have been a bit busy at home and work recently.  Will be starting back up on the white box soon!

I recently wrote about Get-NetworkStatistics.  This basically runs netstat on a remote system and parses the results.  Today, we ran into an issue where we wanted to run ‘set’ on a remote system, and the on-site technician could not get to the command prompt due to certain restrictions.  I already had the framework for running a command remotely, so I made a few adjustments to generalize things.

Getting started

Click here for the function code and ps1.  Once you add the function to your session, you can run commands like this:

image

In this example, I ran ‘set’ against localhost and c-is-ts-91l.  I specified the pattern ‘processors’ to filter the results.  The result is an object for each computer with the computer name, output from the command, errors from the command, the command that ran, and the pattern.

image

In this example, I ran ‘ipconfig /all’ and access the results property.

image

In this example, I ran ‘set’, filtered for ‘computername’, and select only the computer and results.

Do keep in mind the results property is an array.

There are certainly other options for this!  Mark Russinovich’s PsExec is always a solid choice, but collecting and perhaps acting upon the output might require a bit of work.  If you have PowerShell remoting set up in your domain and all systems have PowerShell, that might be a better option.

If you run into any issues or have any suggestions, please let me know!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s