Monday, July 08, 2013

Quick Script: Activate Windows using Powershell


#Windows Activation
    if((cscript "$env:SystemRoot\system32\slmgr.vbs" -dli all) -match "License Status: Licensed")
    {
     
    }
    else
    {   
        Write-Output "Activating Windows..."
        cscript "$env:SystemRoot\system32\slmgr.vbs" -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXx //nologo
        cscript "$env:SystemRoot\system32\slmgr.vbs" -ato //nologo
    } 

2 comments:

  1. Anonymous9:22 AM

    This works better if you use -contains or -notcontains in the conditional statement, rather than -match.

    ReplyDelete
  2. This is beautiful. Thanks.

    ReplyDelete