functions/invoke-d365rearmwindows.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<# .SYNOPSIS Invokes the Rearm of Windows license .DESCRIPTION Function used for invoking the rearm functionality inside Windows .PARAMETER Restart Instruct the cmdlet to restart the machine .EXAMPLE PS C:\> Invoke-D365ReArmWindows This will re arm the Windows installation if there is any activation retries left .EXAMPLE PS C:\> Invoke-D365ReArmWindows -Restart This will re arm the Windows installation if there is any activation retries left and restart the computer. .NOTES Author: Mötz Jensen (@Splaxi) #> function Invoke-D365ReArmWindows { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")] [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 1)] [switch]$Restart ) Write-PSFMessage -Level Verbose -Message "Invoking the rearm process." $instance = Get-CimInstance -Class SoftwareLicensingService -Namespace root/cimv2 -ComputerName . Invoke-CimMethod -InputObject $instance -MethodName ReArmWindows if ($Restart) { Restart-Computer -Force } } |