WMIMethodException with .InstallProductKey
<p>First off, this is my first post, so if I incorrectly posted this in the wrong location, please let me know.  </p>

<p>So, what we're trying to accomplish is building a powershell script that we can throw on our workstation image so that once our Windows 10 boxes are done imaging, that we can click on a powershell script, have it pull the key from the BIOS, and automagically activate it.  That being said, here is the script that we've put together from various sources.</p>

<hr>

<pre><code>(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey | out-file c:\license.txt

$computer = gc env:computername

$key = get-content c:\license.txt

$service = get-wmiObject -query “select * from SoftwareLicensingService” -computername $computer

$service.InstallProductKey($key)        &lt;--------THIS IS WHERE IT FAILS

$service.RefreshLicenseStatus()
</code></pre>

<hr>

<p>We start running into the issues on the line <code>$service.InstallProductKey($key)</code>.  It seems, that no matter how we try to invoke that, it will consistently fail with the error "Exception calling "InstallProductKey"". I've even replaced the variable (<code>$key</code>) with the specific activation key, and it STILL fails with the same error.</p>

<p>The reason we have it outputting to a license txt file part way through is so that we can verify that the command is indeed pulling the product key (which it is).  </p>

<p>At this point, I'm not sure where to go.  It seems that people have tried to do this before, however, nobody has really wrapped up their posting with what worked and/or what didn't.  I can't imagine that this is impossible, but I'm also not fond of wasting anymore time than needed, so anybody that has any insight into this issue, I'd be very grateful.  </p>

<p>We've gotten it to work on two machines that were previously activated, and later deactivated, but on new machines that have been freshly imaged, and have yet to be activated, it will fail every time.</p>