It is available via WMI. Try this.
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey
Note that product keys are mostly being replaced by digital licenses. Therefore this may not work on machine that are using only digital licenses tied to an MS account.