To automatically manage Windows license keys, use slmgr which is a VBScript that you can call from PowerShell. Just make sure that cscript.exe is your default VBScript host. From an elevated PowerShell console, type this:
wscript.exe //H:cscript
Next, run wscript.exe and disable the option "Show Logo". Now you are set.
In Windows Server 2012, for example, you can use slmgr /ipk to register a new one.
If you did register a license key, find out how long it is valid:
slmgr /xpr