Author Posts

July 14, 2016 at 10:19 pm

Is it possible to use Invoke-Command to multiple computers, and then output each computer's results into their own CSV (that does not already exist)? Better yet, one file with one tab per computer containing the results?

I could accomplish this using a foreach loop but that would be quite inefficient compared to the parallelism of Invoke-Command.

I've been searching the forum but haven't found anything yet. Thank you for any input.

July 14, 2016 at 11:08 pm

Objects returned from invoke-command are returned with extra properties, one of which has the computer name. If you capture the results and run that thru group-object on that computer name property, you can loop over the groups and create a csv file for each computer. Creating an excel file can be done, but I'm not experienced with it.

July 14, 2016 at 11:10 pm

You could use the -Asjob parameter of Invoke-Command and then retrieve the job output and place the return from each into individual csv files.

July 14, 2016 at 11:12 pm

+1 Jonathan.

Use -AsJob. Then you can enumerate the child jobs using ForEach and receive their results into a CSV apiece.

July 15, 2016 at 3:47 am

"-AsJob" is the winner, thanks guys. Another simple solution... Still absorbing and assimilating PowerShell MOLs.