Windows Activation Powershell Script

30,993
$computer = gc env:computername

$key = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"

$service = get-wmiObject -query "select * from SoftwareLicensingService" -computername $computer

$service.InstallProductKey($key)

$service.RefreshLicenseStatus()

Taken from http://blogs.technet.com/b/rgullick/archive/2013/06/13/activating-windows-with-powershell.aspx. This has just worked for me when activating machines a couple of days ago

Share:
30,993

Related videos on Youtube

AceHigh
Author by

AceHigh

High-school techie who works with NetLiteracy. Member of FRC. I manage servers and intranets in my free time after-school.

Updated on September 18, 2022

Comments

  • AceHigh
    AceHigh over 1 year

    I'm looking for a method to automate activation Windows 7 machines through PowerShell. We get approximately 50 computers a month and it's slowly increasing, so manual activation is no longer possible with our deadlines. We're on a network where we can't run VAMT while connecting our server to the internet. We would prefer a script that could be written with a program and distributed via FTP. We already have the program framework, so we just need the script.

    We're open to any other options as well, so long as they don't involve servers. We don't have the manpower to maintain another server on our local network.

    We're using this right now:

    slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
    
    slmgr.vbs /ato
    

    This does not successfully activate the machines with the product keys we have.

    Thanks in advance!

    • Ƭᴇcʜιᴇ007
      Ƭᴇcʜιᴇ007 over 9 years
      Windows Vista+ attempts to automatically activate by default. Has this been disabled on your image or something? What edition of Windows 7 are you using? Which license type -- OEM, Retail, MAK, KMS?
    • AceHigh
      AceHigh over 9 years
      We are using Windows 7 pro, OEM keys.
    • Patrick R.
      Patrick R. over 9 years
      Are you using WDS to set the machines up?
    • AceHigh
      AceHigh over 9 years
      Yes, we're using WDS.
  • malakrsnaslava
    malakrsnaslava almost 6 years
    Works on server 2016 SE