Reputation: 454
I have a several scripts that are using PowerCLI to pull info from all of our virtual center servers and dumping into an HMTL file. At this time I have one script setup for each virtual center server, howerver I want to modify it so that I have one main script that will loop through each virtual center and create a HTML for each one instead of having to maintain several different scripts. I have tried declaring each VC as a variable, for example:
$vc = "vc1" , "vc2"
however that only generated one HTML file using the last variable. What would be the best way to accomplish this? Thanks for any help.
Upvotes: 1
Views: 3782
Reputation: 2683
Try this:
"Server01","Server02" | ForEach-Object { Connect-VIServer -Server $_ -User user -Password password; }
Also add the rest of the code that you need to apply to each Server with in the ForEach-Object's { }. You can then name each HTML file with the $_
(server name inside the loop) variable as well.
Upvotes: 2