Edit

Set-OSLicenseInfo

Sets the Windows volume activation type.

Syntax

__AllParameterSets

Set-OSLicenseInfo
    [-ActivationType] <Int32>
    [-AsJob]

Description

The Set-OSLicenseInfo cmdlet changes the volume activation type that the Windows software licensing service uses on the local computer. Use the default activation behavior or require Active Directory-based, Key Management Services (KMS), or token-based activation.

The cmdlet returns a structured object that indicates whether the operation succeeded. If a runtime Common Information Model (CIM) failure occurs, the object includes the available Windows error code and error message. The cmdlet doesn't write the failure to the error stream.

Examples

Example 1: Require Active Directory-based activation

This command configures the local computer to use Active Directory-based activation. Changing the activation type can prevent activation if the required activation infrastructure isn't available, so confirm your organization's activation configuration before you run the command.

$result = Set-OSLicenseInfo -ActivationType 1
$result

Inspect the Success property to determine whether the licensing service applied the change. If Success is $false, inspect ErrorCode and ErrorMessage for failure details.

Example 2: Restore the default activation behavior

This command restores the default volume activation behavior. This operation changes the local computer's licensing configuration, so verify that the default behavior is appropriate before you run the command.

Set-OSLicenseInfo -ActivationType 0

Parameters

-ActivationType

Specifies the volume activation type. The parameter supports these values:

  • 0 - Use the default activation type.
  • 1 - Use Active Directory-based activation.
  • 2 - Use KMS activation.
  • 3 - Use token-based activation.

You must specify this parameter. PowerShell rejects values outside the range 0 through 3 before the cmdlet changes the licensing configuration.

Parameter properties

Type:Int32
Accepted values:0, 1, 2, 3
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Runs the command as a background job when you invoke it through an implicit-remoting wrapper. This wrapper supplies the parameter, and the local OSLicense module function doesn't declare it.

Parameter properties

Type:SwitchParameter
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

Inputs

None

This cmdlet doesn't accept pipeline input.

Outputs

PSCustomObject

When the licensing service applies the activation type, the cmdlet returns an object. Its Success property is $true, and its ActivationType property contains the requested value.

When a runtime CIM operation fails, the cmdlet returns an object. The Success property is $false, the ErrorCode property contains the available Windows HRESULT in hexadecimal format, and the ErrorMessage property contains the available Windows error message. The cmdlet returns no object if it can't find the software licensing service.

Job

When you specify the AsJob parameter through an implicit-remoting wrapper, the cmdlet returns a job object. Use Receive-Job to retrieve the structured result from the completed job.

Notes

Run this cmdlet from an elevated PowerShell session. Parameter-binding and validation failures, including an ActivationType value outside the supported range, occur before the cmdlet invokes the licensing service. The cmdlet doesn't return these failures as structured result objects.