{"id":214,"date":"2025-01-08T07:12:49","date_gmt":"2025-01-08T06:12:49","guid":{"rendered":"https:\/\/digitalmaterial.ch\/blog\/?p=214"},"modified":"2025-01-08T07:37:59","modified_gmt":"2025-01-08T06:37:59","slug":"using-device-product-key-to-activate-windows","status":"publish","type":"post","link":"https:\/\/digitalmaterial.ch\/blog\/using-device-product-key-to-activate-windows\/","title":{"rendered":"Using device product key to activate Windows"},"content":{"rendered":"\n<p>During a recent project, we encountered issues with Windows 11 not being activated on newly purchased and deployed devices. This was quite surprising, given that the devices were bought with a valid Windows 11 licence.<\/p>\n\n\n\n<p>After some digging, we notice that the licence key currently being used ended with &#8211;<code>T83GX<\/code> and after running that through Google we ended on the following Page: <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows-server\/get-started\/kms-client-activation-keys?tabs=server2025%2Cwindows1110ltsc%2Cversion1803%2Cwindows81#windows-11-and-windows-10-semi-annual-channel\">Key Management Services (KMS) client activation and product keys for Windows Server and Windows | Microsoft Learn<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"56\" src=\"https:\/\/digitalmaterial.ch\/blog\/wp-content\/uploads\/2024\/12\/image-7.png\" alt=\"\" class=\"wp-image-215\" srcset=\"https:\/\/digitalmaterial.ch\/blog\/wp-content\/uploads\/2024\/12\/image-7.png 796w, https:\/\/digitalmaterial.ch\/blog\/wp-content\/uploads\/2024\/12\/image-7-300x21.png 300w, https:\/\/digitalmaterial.ch\/blog\/wp-content\/uploads\/2024\/12\/image-7-768x54.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/figure>\n\n\n\n<p>So it seems that because we used a plain Win 11 Image to install the devices before running them through the Autopilot-Deployment Windows used the KMS Key from the Image and was not able to activate as of that. So we dug a bit deeper, and we&#8217;re able to fetch the Original Product Key from the device using the following command:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">PowerShell<\/span><span role=\"button\" tabindex=\"0\" data-code=\"(Get-WmiObject -Class SoftwareLicensingService).OA3xOriginalProductKey\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #DCDCAA\">Get-WmiObject<\/span><span style=\"color: #D4D4D4\"> -Class SoftwareLicensingService).OA3xOriginalProductKey<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>And with the following command, we were able to set it as the currently active key. In the Script we add the <code>\/\/b<\/code> Parameter to prevent the popup that may block the script during automated deployment.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">BAT (Batchfile)<\/span><span role=\"button\" tabindex=\"0\" data-code=\"slmgr \/ipk productKey\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">slmgr \/ipk productKey<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Tested on a few devices and Windows was running smoothly, but we&#8217;re not fans of the good old &#171;Sneaker-IT&#187; and having to run those commands manually on every device. So we created a little script to fetch the Original Key and use it for activation. We can use some regex to validate our product key. This lead us to the following script, which we were able to deploy to all devices and enjoy the rest of the day (or maybe debug the next issues).<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">PowerShell<\/span><span role=\"button\" tabindex=\"0\" data-code=\"try {\n    Write-Host &quot;extracting key&quot;\n    $KeyResult = (Get-WmiObject -Class SoftwareLicensingService).OA3xOriginalProductKey\n    \n    # print the result\n    Write-Host &quot;found key: $KeyResult&quot;\n\n    # Use regex to match the product key format (5 blocks of alphanumeric characters)\n    $regex = '[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}'\n    \n    # Extract the product key\n    $productKey = [regex]::matches($KeyResult, $regex).Value\n    \n    if ($null -eq $productKey) {\n        Write-Host &quot;found key is not valid&quot;\n        exit 1\n    }\n    \n    # register with device key\n    Start-Process &quot;slmgr&quot; -ArgumentList &quot;\/ipk $($productKey) \/\/b&quot; -Wait \n} catch {\n    Write-Host &quot;unable to set product key: $($_.Exception.Message)&quot;\n    exit 1\n}\n\nexit 0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">try<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">Write-Host<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;extracting key&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">$KeyResult<\/span><span style=\"color: #D4D4D4\"> = (<\/span><span style=\"color: #DCDCAA\">Get-WmiObject<\/span><span style=\"color: #D4D4D4\"> -Class SoftwareLicensingService).OA3xOriginalProductKey<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\"># print the result<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">Write-Host<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;found key: <\/span><span style=\"color: #9CDCFE\">$KeyResult<\/span><span style=\"color: #CE9178\">&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\"># Use regex to match the product key format (5 blocks of alphanumeric characters)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">$regex<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&#39;[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\"># Extract the product key<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">$productKey<\/span><span style=\"color: #D4D4D4\"> = [<\/span><span style=\"color: #569CD6\">regex<\/span><span style=\"color: #D4D4D4\">]::matches(<\/span><span style=\"color: #9CDCFE\">$KeyResult<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">$regex<\/span><span style=\"color: #D4D4D4\">).Value<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #569CD6\">$null<\/span><span style=\"color: #D4D4D4\"> -eq <\/span><span style=\"color: #9CDCFE\">$productKey<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">Write-Host<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;found key is not valid&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">exit<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\"># register with device key<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">Start-Process<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;slmgr&quot;<\/span><span style=\"color: #D4D4D4\"> -ArgumentList <\/span><span style=\"color: #CE9178\">&quot;\/ipk <\/span><span style=\"color: #569CD6\">$(<\/span><span style=\"color: #9CDCFE\">$productKey<\/span><span style=\"color: #569CD6\">)<\/span><span style=\"color: #CE9178\"> \/\/b&quot;<\/span><span style=\"color: #D4D4D4\"> -Wait <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">catch<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">Write-Host<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;unable to set product key: <\/span><span style=\"color: #569CD6\">$(<\/span><span style=\"color: #9CDCFE\">$_<\/span><span style=\"color: #DCDCAA\">.Exception.Message<\/span><span style=\"color: #569CD6\">)<\/span><span style=\"color: #CE9178\">&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">exit<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">exit<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">0<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"is-style-default\">Finally, we could deploy above scripts to the clients using Intune and enjoy a smooth rollout of the new devices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During a recent project, we encountered issues with Windows 11 not being activated on newly purchased and deployed devices. This was quite surprising, given that the devices were bought with a valid Windows 11 licence. After some digging, we notice that the licence key currently being used ended with &#8211;T83GX and after running that through [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":358,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[14,35],"class_list":["post-214","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-endpoint-management","tag-powershell","tag-windows-11"],"_links":{"self":[{"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/comments?post=214"}],"version-history":[{"count":17,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/posts\/214\/revisions\/398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/media\/358"}],"wp:attachment":[{"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalmaterial.ch\/blog\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}