https://answers.microsoft.com/en-us/windows/forum/all/how-to-recover-your-windows-product-key/8687ef5d-4d32-41fc-9310-158f8e5f02e3

(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey