I am trying to write a script to automate VDI deployment and I have everything working except for setting the MAC addresses correctly. I am not new to writing scripts but I will say this is the most complicated yet.
I am trying to create an array
with the MAC addresses and then run a foreach
. But I am not sure how to make it use each object in the array
when the foreach
loops.
Please see a piece of the script below:
$array = @('00155d9df9b8','00155d9df921')
$i = 1
$vminstances = Read-Host -Prompt 'How many VMs?'
for ($i=1; $i -le $vminstances; $i++)
The foreach
would run through names of VMs and rename accordingly. But I can't simply use a MAC address with increments of 1 each loop, as they are using different characters, not just numbers.
How can I include each object stored in the array
in each loop?
Perhaps it was never designed to work like this and maybe I need to rethink this. Please could somebody advise?
I would greatly appreciate assistance.