Needed a product key for a Win 7 machine before I reinstalled. I used the instructions on the following page to get me the product code. I required me to use PowerShell.

Guide | How to Find Your Windows Product Key

The basic instructions are to create a .ps1 file then use two command lines to run the query.

I hope this helps someone else out there…