This function will run a process on one or more remote systems, retrieving the output and errors.

The PS1 file here contains a function.  You can either add this function to a profile or module of your own, copy and paste the code to your current session, or dot source it like this: ."\\path\to\New-RemoteProcess.ps1".

Once the function is available, use it as desired; for example: New-RemoteProcess -computername wbf, c-is-ts-91 -command "set" -pattern "logonserver" | Format-Table -AutoSize.  Run Get-Help New-RemoteProcess -Full for more details.

 

PowerShell
Edit|Remove
# dot source the function  
    . "\\Path\To\New-RemoteProcess.ps1"  
  
# Get help for New-RemoteProcess 
    Get-Help New-RemoteProcess -Full 
 
# Run 'set' on c-is-hyperv-1.  Return raw output (not an object with computer, results, etc.) 
    New-RemoteProcess -ComputerName c-is-hyperv--Command "set" -Raw 
 
# Run 'Set' on localhost and c-is-hyperv-1.  Filter output to lines that match '^Path='.  Only display the Computer and Results 
    New-RemoteProcess -ComputerName localhost, c-is-hyperv--Command "set" -Pattern "^Path=" | Select-Object computer, results
 
This function leverages WMI to start the process, and runs it through CMD rather than PowerShell.  It already uses redirection to send the output and errors to text files.
Please let me know if you run into any issues or have any suggestions!
2015 edit: revisted this function for a few minutes.  It was one of my first functions, quite poor.  Still needs work, but cleaned up some problems.