Invoke-Command - Separate CSV for Each Computer

This topic contains 4 replies, has 4 voices, and was last updated by  Aaron Hardy 1 year, 10 months ago.

  • Author
  • #47012

    Aaron Hardy

    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.

  • #47017

    Craig Duff

    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.

  • #47019

    Jonathan Warnken

    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.

  • #47021

    Don Jones

    +1 Jonathan.

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

  • #47027

    Aaron Hardy

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

You must be logged in to reply to this topic.