title: Cannot convert argument second time in Powershell
body: <p>I am trying to call a web service. If I just start up Powershell fresh, the following code runs perfectly. Any subsequent run will give the following error.</p>
  
  <pre><code>Cannot convert argument "fieldsWithValues", with value: 
  "FileHold.LibraryManager.FieldWithValue[]", for "SetMetadata" to type 
  "FileHold.LibraryManager.FieldWithValue[]": "Cannot convert the 
  "FileHold.LibraryManager.FieldWithValue" value of type 
  "FileHold.LibraryManager.FieldWithValue" to type 
  "FileHold.LibraryManager.FieldWithValue"."
  At Z:\VM_Transfer\Customers\Oregon\UpdateMetadata\CannotConvertTest.ps1:19 char:1
  </code></pre>
  
  <p>Here is the code with the problem.</p>
  
  <pre><code>$fh = "http://fileholdtest8/fh/filehold"
  
  $uri = $fh + "/UserRoleManager/SessionManager.asmx?WSDL"
  $SessionManager = New-WebServiceProxy -Uri $uri -Namespace FileHold.SessionManager
  $sessionId = $SessionManager.StartSession( 'sysadm', '12345', 4 )
  
  $uri = $fh + "/LibraryManager/DocumentManager.asmx?WSDL"
  $dm = New-WebServiceProxy -Uri $uri -Namespace FileHold.LibraryManager
  
  $dm.CookieContainer = New-Object System.Net.CookieContainer
  $cookie = New-Object System.Net.Cookie( 'FHLSID', $sessionId, "/", ([System.Uri]$dm.Url).Host )
  $dm.CookieContainer.Add( $cookie )    
  
  $newFieldValue = [FileHold.LibraryManager.FieldWithValue]::new()
  $newFieldValue.FieldId = 1007
  $newFieldValue.FieldValue = $true
  [FileHold.LibraryManager.FieldWithValue[]]$fieldsWithValues = @( $newFieldValue )
  
  $dm.SetMetadata( 4033, 1002, "EmployeeInfo_filled1-test", $fieldsWithValues, $false, $null )
  </code></pre>
  
  <p>What do I need to do to be able to run this every time without restarting the ISE. </p>
  
  <p>Btw. I can use this technique to call other methods without any problem as long as their parameters are simple types. It seems the issue only occurs when I have a complex object like <strong>FileHold.LibraryManager.FieldWithValue</strong>.</p>
  
  <p>PSVersion = 5.1.14393.1532 </p>