Skip to content

Commit 0d1a35c

Browse files
committed
new activation method
1 parent f8ff745 commit 0d1a35c

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

  • HandsOnLabs/06-TestingWindowsServerInsider

‎HandsOnLabs/06-TestingWindowsServerInsider/readme.md‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,23 @@ Once you're logged in the management machine, simply paste following PowerShell
4646
#endregion
4747
4848
#region install keys and activate servers
49-
50-
$LicenseKey="2KNJJ-33Y9H-2GXGX-KMQWH-G6H67"
51-
52-
#install and activate on Management machine
53-
cscript c:\windows\system32\slmgr.vbs /ipk $LicenseKey
54-
cscript c:\windows\system32\slmgr.vbs /ato
55-
56-
#install and activate on cluster nodes
57-
Invoke-Command -ComputerName $Servers -ScriptBlock {
58-
cscript c:\windows\system32\slmgr.vbs /ipk $using:LicenseKey
59-
cscript c:\windows\system32\slmgr.vbs /ato
49+
$AllServers=@("Management")+$Servers
50+
Invoke-Command -ComputerName $AllServers -ScriptBlock {
51+
$key = '2KNJJ-33Y9H-2GXGX-KMQWH-G6H67'
52+
#install product key
53+
$sls = Get-CimInstance -ClassName 'SoftwareLicensingService'
54+
$arg = @{ 'ProductKey' = $key }
55+
Invoke-CimMethod -InputObject $sls -MethodName 'InstallProductKey' -Arguments $arg
56+
#activate
57+
$slp = Get-CimInstance -ClassName 'SoftwareLicensingProduct' -Filter 'PartialProductKey <> null and ApplicationId = ''55c92734-d682-4d71-983e-d6ec3f16059f'''
58+
Invoke-CimMethod -InputObject $slp -MethodName 'Activate'
59+
#refresh license status
60+
$sls = Get-CimInstance -ClassName 'SoftwareLicensingService'
61+
Invoke-CimMethod -InputObject $sls -MethodName 'RefreshLicenseStatus'
6062
}
6163
6264
#check status
63-
Get-CimInstance SoftwareLicensingProduct -CimSession $Servers |
65+
Get-CimInstance SoftwareLicensingProduct -CimSession $AllServers |
6466
Where-Object { $_.PartialProductKey -and $_.ApplicationID -eq '55c92734-d682-4d71-983e-d6ec3f16059f' } |
6567
Select-Object Name, Description, LicenseStatus, PartialProductKey, PSComputerName,
6668
@{N='LicenseStatusText';E={

0 commit comments

Comments
 (0)