title: Using array in powershell function
body: <p>I have function in powershell with prarametres: vmname, hypervname, cred:</p>
  
  <pre><code>function backup-VM ([string]$vmname, [string]$hypervname,$cred)
  {
  ......
  }
  </code></pre>
  
  <p>I want to use this function in loop, using values from array, like this:</p>
  
  <pre><code>$arrayVM = Get-VM | select Name / get lists of Vitrual Machines
  $arrayVMHost = Get-VMHost | select Name / get list of Vitrual Machines Host
  
  for ($i=0; $i -lt $arrayVM.length; $i++) {
      backup-vm $arrayVM[$i] $arrayVMHost[0] $credentials
  }
  
  $arrayVM.Clear()
  $arrayVMHost.Clear()
  </code></pre>
  
  <p>But this, doesn't work. What is wrong? How to pass values from array to function call?</p>