Activating windows via powershell
hi, trying activate windows via powershell , have found script:
https://social.technet.microsoft.com/forums/office/en-us/9fcdb039-f9f0-48a9-8253-1f52c0257a80/activate-windows-using-powershell?forum=winservergen
problem is, cannot run it. exact version of script:
##### getting serial key bios #### $key = (wmic path softwarelicensingservice oa3xoriginalproductkey)[2];break # getting activation object# $service = get-wmiobject -query 'select * softwarelicensingservice' ##### install product key , activate #### $service.installproductkey($key) $service.refreshlicensestatus()
i tried create $key parameter manually this
$key = "xxx-xxx-xxx-xxx";break
i tried both variations without break
my problem line:
$service.installproductkey($key)
it gives me following error:
exception calling "installproductkey" : "" @ line:1 char:1 + $service.installproductkey($key) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [], methodinvocationexception + fullyqualifiederrorid : wmimethodexception
if try echo $key file, or write $key in powershell seems contains key , newline.
i suspect new line problem here, scripts works if manually insert key this:
# getting activation object# $service = get-wmiobject -query 'select * softwarelicensingservice' ##### install product key , activate #### $service.installproductkey("xxx-xxx-xxx-xxx") $service.refreshlicensestatus()
first sort out doing , use correct code:
$service = get-wmiobject -query 'select * softwarelicensingservice' $service.oa3xoriginalproductkey $key=$service.oa3xoriginalproductkey $service.installproductkey($key)
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment