Add a state to activate a computer with it's BIOS key

This commit is contained in:
Adam Goldsmith 2020-01-16 12:38:05 -05:00
parent cf89324625
commit aaf62dc252

22
_states/auto_activate.py Normal file
View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, print_function
def auto_activate(name):
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
if __salt__['license.licensed']():
ret['comment'] = 'Windows is already activated'
return ret
licensing = __salt__['cmd.powershell']("Get-WmiObject SoftwareLicensingService")
if licensing is not None:
OEM_key = licensing.get('OA3xOriginalProductKey', '')
if OEM_key != "":
return __states__['license.activate'](OEM_key)
ret['comment'] = 'No Windows Key found in BIOS'
ret['result'] = False
return ret