title: Trying to get Powershell to work with an API
body: <p>I am trying to write a Powershell script to work with a Microsoft API, and being new to this, I have come across an error that I cannot seem to get past.</p>
  
  <p>Error:</p>
  
  <blockquote>
  <pre><code>Cannot find an overload for "UpdateDeviceValues" and the argument count: "3".
  At C:\PowerShellScripts\API-UpdateDeviceValues-ICC.ps1:13 char:37
  + $accounts = $pmws.UpdateDeviceValues &lt;&lt;&lt;&lt; ('18B81F1FD790','DisableICC','True');
      + CategoryInfo          : NotSpecified: (:) [], MethodException
      + FullyQualifiedErrorId : MethodCountCouldNotFindBest
  </code></pre>
  </blockquote>
  
  <p>From my searches, it seems that the API is requiring three values to be sent to it, but that is what I am sending.</p>
  
  <p>My code:</p>
  
  <pre><code>$pmws = New-Object PrincipalManagement;
  $pmws.Credentials = $cred;
  
  $pmws.url = "http://172.31.9.2/bss/PrincipalManagement.asmx";
  
  $accounts = $pmws.UpdateDeviceValues('18B81F1FD790','DisableICC','True');
  
  $accounts
  </code></pre>
  
  <p>Any help with this error would be much appreciated.  I am rather new to this, getting Powershell to work with APIs.   </p>
  
  <p>This is the SOAP 1.1 example for the API.</p>
  
  <pre><code>POST /bss/PrincipalManagement.asmx HTTP/1.1
  Host: 172.31.9.2
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  SOAPAction: "http://www.microsoft.com/iptv/bss/UpdateDeviceValues"
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope"&gt;
    &lt;soap:Body&gt;
      &lt;UpdateDeviceValues xmlns="http://www.microsoft.com/iptv/bss"&gt;
        &lt;deviceExternalID&gt;string&lt;/deviceExternalID&gt;
        &lt;deviceValues&gt;
          &lt;DeviceValue Key="string" Value="string" /&gt;
          &lt;DeviceValue Key="string" Value="string" /&gt;
        &lt;/deviceValues&gt;
      &lt;/UpdateDeviceValues&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I can run this in PowerShell:</p>
  
  <pre><code>&gt; $pmws | Get-Member
  </code></pre>
  
  <p>I get a long list of the APIs, and in that list is the one I am trying to use...</p>
  
  <p>TypeName: PrincipalManagement
  Name - MemberType - Definition<br>
  UpdateDeviceValues - Method - System.Void UpdateDeviceValues(string deviceExternalID, DeviceValue[] deviceValues)</p>
  
  <p>Much thanks to Chamele0n!  Answer found!
  I was missing how to properly format the parameters when calling the method. 
  This works!</p>
  
  <pre><code>$Account = "18B81F1FD790"
  
  $deviceValue = New-Object ($ns + ".DeviceValue") 
  $deviceValue.Key = "DisableICC" 
  $deviceValue.Value = "True" 
  
  $accounts = $pmws.UpdateDeviceValues($Account, $deviceValue)
  </code></pre>
  
  <p>Thanks,
  Jason...</p>