Edit

Invoke-ADLicense

Performs Active Directory-based licensing operations.

Syntax

ActivateOnline

Invoke-ADLicense
    [-ActivateOnline]
    [-ProductKey <String>]
    [-ConfirmationID <String>]
    [-ActivationObjectName <String>]
    [-AsJob]

ActivateForest

Invoke-ADLicense
    [-ActivateForest]
    [-ProductKey <String>]
    [-ConfirmationID <String>]
    [-ActivationObjectName <String>]
    [-AsJob]

DeleteActivationObjects

Invoke-ADLicense
    [-DeleteActivationObjects <String>]
    [-AsJob]

None

Invoke-ADLicense
    [-AsJob]

Description

The Invoke-ADLicense cmdlet performs Active Directory-based activation and deletes Active Directory activation objects. Online activation calls the software licensing service to create an activation object. Forest activation deposits an offline activation confirmation. The deletion operation accepts an activation object's distinguished or relative name.

The cmdlet returns structured objects when it completes operations or catches failures. It returns no object when the software licensing service query returns no instance or when you don't select an operation.

Examples

Example 1: Deposit a fictitious offline activation confirmation

Caution

This example uses a fictitious product key, confirmation ID, and activation object name. The command changes Active Directory-based activation state. After you verify the intended licensing operation, replace the values only in an authorized test environment.

$activationParameters = @{
    ActivateForest      = $true
    ProductKey           = 'AAAAA-BBBBB-CCCCC-DDDDD-EEEEE'
    ConfirmationID       = '000000000000000000000000000000000000000000000000'
    ActivationObjectName = 'Fabrikam-Docs-Activation-Object'
}

Invoke-ADLicense @activationParameters

This example requests forest activation by depositing a fictitious offline activation confirmation. It doesn't represent an actual activation or include command output.

Example 2: Delete a fictitious activation object by relative name

Caution

The cmdlet immediately deletes an activation object and doesn't prompt for confirmation. The object name in this example is fictitious. Verify the target object and your recovery plan before you run a deletion command in an authorized environment.

Invoke-ADLicense -DeleteActivationObjects 'Fabrikam-Docs-Obsolete-Activation-Object'

This example requests deletion by relative name. The cmdlet resolves a relative name under the CN=Activation Objects,CN=Microsoft SPP container in the configuration naming context. It doesn't represent an actual deletion or include command output.

Parameters

-ActivateForest

Requests forest activation by depositing an offline activation confirmation through the software licensing service. The cmdlet validates ProductKey and ConfirmationID at runtime and requires values for both parameters.

Parameter properties

Type:SwitchParameter
Supports wildcards:False
DontShow:False

Parameter sets

ActivateForest
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ActivateOnline

Requests online Active Directory-based activation through the software licensing service. The cmdlet validates ProductKey at runtime and requires a value for online activation.

Parameter properties

Type:SwitchParameter
Supports wildcards:False
DontShow:False

Parameter sets

ActivateOnline
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ActivationObjectName

Specifies the name of the activation object for online or forest activation. When you omit this parameter, the cmdlet passes an empty string to the corresponding software licensing service method.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

ActivateOnline
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ActivateForest
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Runs the command as a background job. The implicit-remoting wrapper that exposes this command adds this parameter; the Invoke-ADLicense function in the OSLicense module doesn't declare it. Use Receive-Job to retrieve the operation result.

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

-ConfirmationID

Specifies the offline activation confirmation ID. The function declares this parameter for both activation parameter sets but uses it only with ActivateForest. It validates the value at runtime and requires it for forest activation. The ActivateOnline operation ignores this value.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

ActivateOnline
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ActivateForest
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DeleteActivationObjects

Specifies an activation object to delete. Enter a distinguished name that starts with CN=, or enter the relative name without the CN= prefix for an object in the CN=Activation Objects,CN=Microsoft SPP container. The cmdlet uses Remove-ADObject when the ActiveDirectory module is available. Otherwise, it uses Active Directory Service Interfaces (ADSI) to delete the object tree.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

DeleteActivationObjects
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ProductKey

Specifies the product key for online or forest activation. The cmdlet validates this value at runtime and requires it for either activation operation. A successful activation result includes this value in its ProductKey property. Protect command output that contains a product key.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

ActivateOnline
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ActivateForest
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

For a successful online or forest activation request, the cmdlet returns an object with these properties:

  • Success is $true.
  • Operation is ActivateOnline or ActivateForest.
  • ProductKey is the value that you supply to ProductKey.
  • ActivationObjectName is the value that you supply to ActivationObjectName, or an empty string when you omit ActivationObjectName.

For a successful deletion, the cmdlet returns an object with these properties:

  • Success is $true.
  • Operation is DeleteActivationObject.
  • ActivationObject is the value that you supply to DeleteActivationObjects.

When the cmdlet catches a failure, it returns an object with these properties:

  • Success is $false.
  • ErrorCode is the Common Information Model (CIM) error_Code value. The cmdlet formats the value as an eight-digit hexadecimal string with a 0x prefix. If CIM error data doesn't provide a code, ErrorCode is $null.
  • ErrorMessage is the CIM error_WindowsErrorMessage value when CIM provides one. Otherwise, it's the exception message or the string representation of the error that the cmdlet catches.

The cmdlet returns no object when the CIM query returns no SoftwareLicensingService instance or when you don't select an operation.

Job

When you use AsJob, the implicit-remoting wrapper returns a job object rather than the operation result. Use Receive-Job to receive the underlying structured result. If the underlying command returns no object, Receive-Job produces no output.

Notes

To invoke software licensing service methods and modify Active Directory activation objects, run this cmdlet with the necessary permissions.

The Invoke-ADLicense function doesn't implement SupportsShouldProcess. For deletion, it calls Remove-ADObject without confirmation when the ActiveDirectory module is available. Otherwise, it calls the ADSI DeleteTree() method.

The function metadata doesn't mark the ProductKey, ConfirmationID, and activation switches as mandatory. The function performs runtime validation: both activation operations require a product key, and forest activation also requires a confirmation ID.

The generated implicit-remoting wrapper adds AsJob to every parameter set. This wrapper intentionally retains the parameter even though the module function source doesn't include it.