0

Can I get and set the product key from bios in 1 line using cmd?

Currently I just use a batch file that contains

powershell.exe -c "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey" | clip

To get the product key

How can I instead just straight up install the key to the bios. Something like

powershell.exe -c "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey" | slmgr

Is this possible?

1
  • Did you even try what you posted? Did you read the MS Docs on slmgr.vbs details to determine if it is designed to take piped input from some other script??
    – postanote
    Jun 30, 2021 at 21:38

1 Answer 1

0

Continuing from my comment.

As we all know, slmgr is a .vbs that expect specific input, as defined in the MS Docs on that VBS script.

That VBS file simply calls: SoftwareLicensingService and SoftwareLicensingProduct WMI classes, which means you can code this out yourself. For example:

function Install-LicenseFile ($FilePath)
{
    $SoftwareLicensingService=Get-CimInstance SoftwareLicensingService -KeyOnly
    $FileContent=[System.IO.File]::ReadAllText($FilePath,[System.Text.Encoding]::Default)
    $SoftwareLicensingService | Invoke-CimMethod -MethodName InstallLicense -Arguments @{License=$FileContent}
}

or this way...

https://4sysops.com/archives/change-a-product-key-remotely-with-powershell

...or see this approach instead:

The PSSlmgr PowerShell module is intended to be a replacement of slmgr.vbs.

https://github.com/it-praktyk/PSSlmgr

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .