{"id":1793,"date":"2012-04-30T09:15:43","date_gmt":"2012-04-30T16:15:43","guid":{"rendered":"https:\/\/mmman.itgroove.net\/2012\/04\/powershell-powertip-how-to-get-the-windows-product-key\/"},"modified":"2023-02-24T21:47:04","modified_gmt":"2023-02-24T21:47:04","slug":"powershell-powertip-how-to-get-the-windows-product-key","status":"publish","type":"post","link":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/","title":{"rendered":"PowerShell PowerTip \u2013 How to get the Windows Product Key"},"content":{"rendered":"<p>This is copied from a daily email I get from powershell.com<\/p>\n<h4>Getting Windows Product Key<\/h4>\n<p>Ever wanted to read out the Windows license key? In the Windows Registry, this key is present, but it is stored as a digital ID. To convert it back to the license key used to originally license the product, try this function. It uses some serious math:<\/p>\n<p style=\"line-height: normal;margin: 0cm 0cm 0pt\" class=\"MsoNormal\"><font face=\"Courier New\"><span><font color=\"#0000ff\"><font style=\"font-size: 10pt\">function<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#5f9ea0\">Get-ProductKey<\/font><\/span><\/font><span><font style=\"font-size: 10pt\"> {<\/font><\/span><\/font><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160; <br \/>&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$map<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span><font color=\"#ff0000\">=<\/font><\/span><\/font><span><font style=\"font-size: 10pt\" color=\"#800000\">&quot;BCDFGHJKMPQRTVWXY2346789&quot;<\/font><\/span><\/font>     <br \/><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$value<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> (<\/span><span><font color=\"#5f9ea0\">get-itemproperty<\/font><\/span><span> <\/span><span><font color=\"#800000\">&quot;HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion&quot;<\/font><\/span><span>).<\/span><span><font color=\"#8b4513\">digitalproductid<\/font><\/span><\/font><span><font style=\"font-size: 10pt\">[0x34..0x42]<\/font><\/span><\/font><span><font face=\"Arial\"><font style=\"font-size: 9pt\">          <br \/>&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$ProductKey<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> <\/span><\/font><span><font style=\"font-size: 10pt\" color=\"#800000\">&quot;&quot;<\/font><\/span><\/font><span><font face=\"Arial\"><font style=\"font-size: 9pt\">          <br \/>&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#0000ff\"><font style=\"font-size: 10pt\">for<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> (<\/span><span><font color=\"#800080\">$i<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> 24<\/span><span><font color=\"#0000ff\">;<\/font><\/span><span> <\/span><span><font color=\"#800080\">$i<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">-ge<\/font><\/span><span> 0<\/span><span><font color=\"#0000ff\">;<\/font><\/span><span> <\/span><span><font color=\"#800080\">$i<\/font><\/span><span><font color=\"#ff0000\">&#8212;<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">) {<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$r<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\"> 0<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#0000ff\"><font style=\"font-size: 10pt\">for<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> (<\/span><span><font color=\"#800080\">$j<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> 14<\/span><span><font color=\"#0000ff\">;<\/font><\/span><span> <\/span><span><font color=\"#800080\">$j<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">-ge<\/font><\/span><span> 0<\/span><span><font color=\"#0000ff\">;<\/font><\/span><span> <\/span><span><font color=\"#800080\">$j<\/font><\/span><span><font color=\"#ff0000\">&#8212;<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">) {<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$r<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> (<\/span><span><font color=\"#800080\">$r<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">*<\/font><\/span><span> 256) <\/span><span><font color=\"#5f9ea0\">-bxor<\/font><\/span><span> <\/span><span><font color=\"#800080\">$value<\/font><\/span><span>[<\/span><span><font color=\"#800080\">$j<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">]<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$value<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span>[<\/span><span><font color=\"#800080\">$j<\/font><\/span><span>] <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> [<\/span><span><font color=\"#0000ff\">math<\/font><\/span><span>]::<\/span><span><font color=\"#8b4513\">Floor<\/font><\/span><span>([<\/span><span><font color=\"#0000ff\">double<\/font><\/span><span>](<\/span><span><font color=\"#800080\">$r<\/font><\/span><span><font color=\"#ff0000\">\/<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">24))<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$r<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> <\/span><span><font color=\"#800080\">$r<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">%<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\"> 24<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">}<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$ProductKey<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> <\/span><span><font color=\"#800080\">$map<\/font><\/span><span>[<\/span><span><font color=\"#800080\">$r<\/font><\/span><span>] <\/span><span><font color=\"#ff0000\">+<\/font><\/span><span> <\/span><\/font><span><font style=\"font-size: 10pt\" color=\"#800080\">$ProductKey<\/font><\/span><\/font>     <br \/><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#0000ff\"><font style=\"font-size: 10pt\">if<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> ((<\/span><span><font color=\"#800080\">$i<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">%<\/font><\/span><span> 5) <\/span><span><font color=\"#ff0000\">-eq<\/font><\/span><span> 0 <\/span><span><font color=\"#ff0000\">-and<\/font><\/span><span> <\/span><span><font color=\"#800080\">$i<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">-ne<\/font><\/span><\/font><\/font><span><font face=\"Courier New\"><font style=\"font-size: 10pt\"> 0) {<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$ProductKey<\/font><\/font><\/span><font style=\"font-size: 10pt\"><span> <\/span><span><font color=\"#ff0000\">=<\/font><\/span><span> <\/span><span><font color=\"#800000\">&quot;-&quot;<\/font><\/span><span> <\/span><span><font color=\"#ff0000\">+<\/font><\/span><span> <\/span><\/font><span><font style=\"font-size: 10pt\" color=\"#800080\">$ProductKey<\/font><\/span><\/font>     <br \/><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/span><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">}<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160; <\/font><\/font><\/span><span><font face=\"Courier New\"><font style=\"font-size: 10pt\">}<\/font><\/font>       <br \/><\/span><span><font face=\"Arial\"><font style=\"font-size: 9pt\">&#160;&#160;&#160; <\/font><\/font><\/span><font face=\"Courier New\"><span><font color=\"#800080\"><font style=\"font-size: 10pt\">$ProductKey<\/font><\/font><\/span><font style=\"font-size: 10pt\">        <br \/><\/font><span><font style=\"font-size: 10pt\">} <\/font><\/span><\/font><\/p>\n<p>&#160;<\/p>\n<p><a title=\"http:\/\/powershell.com\/cs\/blogs\/tips\/archive\/2012\/04\/30\/getting-windows-product-key.aspx\" href=\"http:\/\/powershell.com\/cs\/blogs\/tips\/archive\/2012\/04\/30\/getting-windows-product-key.aspx\">http:\/\/powershell.com\/cs\/blogs\/tips\/archive\/2012\/04\/30\/getting-windows-product-key.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is copied from a daily email I get from powershell.com Getting Windows Product Key Ever wanted to read out the Windows license key? In the Windows Registry, this key is present, but it is stored as a digital ID. To convert it back to the license key used to originally license the product, try &hellip; <a href=\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\"><\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[24,31,33],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive\" \/>\n<meta property=\"og:description\" content=\"This is copied from a daily email I get from powershell.com Getting Windows Product Key Ever wanted to read out the Windows license key? In the Windows Registry, this key is present, but it is stored as a digital ID. To convert it back to the license key used to originally license the product, try &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\" \/>\n<meta property=\"og:site_name\" content=\"Archive\" \/>\n<meta property=\"article:published_time\" content=\"2012-04-30T16:15:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-24T21:47:04+00:00\" \/>\n<meta name=\"author\" content=\"Colin Phillips (Alumni)\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Colin Phillips (Alumni)\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\",\"url\":\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\",\"name\":\"PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive\",\"isPartOf\":{\"@id\":\"https:\/\/regroove.ca\/archive\/#website\"},\"datePublished\":\"2012-04-30T16:15:43+00:00\",\"dateModified\":\"2023-02-24T21:47:04+00:00\",\"author\":{\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b\"},\"breadcrumb\":{\"@id\":\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog Archive\",\"item\":\"https:\/\/regroove.ca\/archive\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell PowerTip \u2013 How to get the Windows Product Key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/regroove.ca\/archive\/#website\",\"url\":\"https:\/\/regroove.ca\/archive\/\",\"name\":\"Archive\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/regroove.ca\/archive\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b\",\"name\":\"Colin Phillips (Alumni)\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g\",\"caption\":\"Colin Phillips (Alumni)\"},\"url\":\"https:\/\/regroove.ca\/archive\/author\/cphillips\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive","og_description":"This is copied from a daily email I get from powershell.com Getting Windows Product Key Ever wanted to read out the Windows license key? In the Windows Registry, this key is present, but it is stored as a digital ID. To convert it back to the license key used to originally license the product, try &hellip;","og_url":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/","og_site_name":"Archive","article_published_time":"2012-04-30T16:15:43+00:00","article_modified_time":"2023-02-24T21:47:04+00:00","author":"Colin Phillips (Alumni)","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Colin Phillips (Alumni)","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/","url":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/","name":"PowerShell PowerTip \u2013 How to get the Windows Product Key - Archive","isPartOf":{"@id":"https:\/\/regroove.ca\/archive\/#website"},"datePublished":"2012-04-30T16:15:43+00:00","dateModified":"2023-02-24T21:47:04+00:00","author":{"@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b"},"breadcrumb":{"@id":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/regroove.ca\/archive\/2012\/04\/30\/powershell-powertip-how-to-get-the-windows-product-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Archive","item":"https:\/\/regroove.ca\/archive\/"},{"@type":"ListItem","position":2,"name":"PowerShell PowerTip \u2013 How to get the Windows Product Key"}]},{"@type":"WebSite","@id":"https:\/\/regroove.ca\/archive\/#website","url":"https:\/\/regroove.ca\/archive\/","name":"Archive","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/regroove.ca\/archive\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b","name":"Colin Phillips (Alumni)","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g","caption":"Colin Phillips (Alumni)"},"url":"https:\/\/regroove.ca\/archive\/author\/cphillips\/"}]}},"_links":{"self":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/1793"}],"collection":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/comments?post=1793"}],"version-history":[{"count":1,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/1793\/revisions"}],"predecessor-version":[{"id":2001,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/1793\/revisions\/2001"}],"wp:attachment":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/media?parent=1793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/categories?post=1793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/tags?post=1793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}