title: PScredentials Overload error
body: <p>Im using invoke command to delete a service on a remote vm.</p>
  
  <p>Im using the PScredentials for passing credentials in the invoke command.</p>
  
  <p>Im getting my User and Password from an XML file.</p>
  
  <p>When im running the script with only 1 remote vm theres no problem.</p>
  
  <p>When im trying to run the script on more then 1 remote vm (With a foreach loop) i get an error :</p>
  
  <pre><code>New-Object : Cannot find an overload for "PSCredential" and the argument 
  count: "2".
  At line:17 char:15
  + ... redential = New-Object System.Management.Automation.PSCredential($use 
  ...
  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : InvalidOperation: (:) [New-Object], 
  MethodException
  + FullyQualifiedErrorId : 
  ConstructorInvokedThrowException,Microsoft
  .PowerShell.Commands.NewObjectCommand
  </code></pre>
  
  <p>I isolated the issue to a small script that im posting :</p>
  
  <pre><code>[xml]$xml = Get-Content "PUT Your Path Here" 
  $vmList = $xml.configuration.vmList
  
  
  
  forEach ($vm in $vmList) {
  
  $vmUser = $vm.vm.vmUser
  $vmPass = $vm.vm.vmPass
  
  
  
  #Creating PScredentials
  $password = $vmPass | ConvertTo-SecureString -asPlainText -Force
  $username = $vmUser
  $credential = New-Object 
  System.Management.Automation.PSCredential($username,$password)
  
  Echo $credential
  
  }
  </code></pre>
  
  <p>The XML : </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
      &lt;vCenterServerName&gt;Server IP&lt;/vCenterServerName&gt;
      &lt;vCenterUser&gt;server user&lt;/vCenterUser&gt;
      &lt;vCenterPass&gt;Server pass&lt;/vCenterPass&gt;
      &lt;localTempDirectory&gt;Your Local Host&lt;/localTempDirectory&gt;
      &lt;vmList&gt;
          &lt;vm&gt;
              &lt;vmName&gt;VMname&lt;/vmName&gt;
              &lt;vmIP&gt;Put Server IP&lt;/vmIP&gt;
              &lt;vmUser&gt;User&lt;/vmUser&gt;
              &lt;vmPass&gt;pass&lt;/vmPass&gt;
              &lt;vmTargetFolder&gt;Put Your Path&lt;/vmTargetFolder&gt;
                 &lt;/vm&gt;
          &lt;vm&gt;
              &lt;vmName&gt;VMname&lt;/vmName&gt;
              &lt;vmIP&gt;Put Server IP&lt;/vmIP&gt;
              &lt;vmUser&gt;User&lt;/vmUser&gt;
              &lt;vmPass&gt;pass&lt;/vmPass&gt;
              &lt;vmTargetFolder&gt;Put Your Path&lt;/vmTargetFolder&gt;
                 &lt;/vm&gt;
      &lt;/vmList&gt;
  &lt;/configuration&gt;
  </code></pre>