Hoping someone here has solved a similar problem and can point me in the right direction, basically I have an array of “Server” objects containing customer and server info, and need to run a remote command on each (limited to say 20 concurrent connections) and attach the output to its respective Server object. This allows me to generate say a spreadsheet containing the customer name, how many licences they have, and the script output of when they last logged in.
While I can pass these Servers to Invoke-Command the returned objects only have the ComputerName added (as it gets converted to String for the cmdlet). I can try to link the output back to the Server objects, but I found this is messy and somewhat unreliable - for example if multiple objects are returned.
I now realise I need to write a function to do the above, but am unsure of the best way to go about it? I tried a Workflow but an error is thrown saying it probably won’t work very well, when bypassed it does do the job but unusably slowly.