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:

Anonymous said...

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

fahadysf said...

This is beautiful. Thanks.