title: Call array objects in a foreach loop in Powershell
body: <p>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.</p>
  <p>I am trying to create an <code>array</code> with the MAC addresses and then run a <code>foreach</code>. But I am not sure how to make it use each object in the <code>array</code> when the <code>foreach</code> loops.</p>
  <p>Please see a piece of the script below:</p>
  <pre><code>$array = @('00155d9df9b8','00155d9df921')
  
  $i = 1
  
  $vminstances = Read-Host -Prompt 'How many VMs?'
  
  for ($i=1; $i -le $vminstances; $i++)
  </code></pre>
  <p>The <code>foreach</code> 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.</p>
  <p>How can I include each object stored in the <code>array</code> in each loop?</p>
  <p>Perhaps it was never designed to work like this and maybe I need to rethink this. Please could somebody advise?</p>
  <p>I would greatly appreciate assistance.</p>