New-CMTSStepConditionRegistry

Create a registry setting condition for a task sequence step.

Syntax

New-CMTSStepConditionRegistry
   -RegistryKey <String>
   -RegistryOperator <VariableOperatorType>
   [-RegistryValueData <String>]
   [-RegistryValueName <String>]
   -RootKey <RegistryRootKeyType>
   [-ValueType <RegistryValueType>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Use this cmdlet to create a registry setting condition object for a task sequence step. Then use one of the New-CMTSStep* or Set-CMTSStep* cmdlets with the Condition or AddCondition parameters. For example, Set-CMTSStepApplyDataImage.

For more information, see Use the task sequence editor: Conditions.

Note

Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.

Examples

Example 1

This example first creates the condition object for the registry setting that checks the Configuration Manager client log level.

It then uses the Set-CMTSStepSetDynamicVariable cmdlet to add this condition object to the Set Dynamic Variables step of the Default OS deployment task sequence.

$root = "HKeyLocalMachine"
$key = "SOFTWARE\Microsoft\CCM\Logging\@Global"
$name = "LogLevel"
$type = "RegistryDWord"
$value = 1

$condition = New-CMTSStepConditionRegistry -RootKey $root -RegistryKey $key -RegistryOperator Equals -RegistryValueName $name -ValueType $type -RegistryValueData $value

$tsNameOsd = "Default OS deployment"
$tsStepNameDynVar = "Set Dynamic Variables"

Set-CMTSStepSetDynamicVariable -TaskSequenceName $tsNameOsd -StepName $tsStepNameDynVar -AddCondition $condition

This sample script creates the following condition on the step:

Registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CCM\Logging\@Global\LogLevel" (REG_DWORD) equals "1"

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisableWildcardHandling

This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ForceWildcardHandling

This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RegistryKey

Specify the registry key path to check. For example, with the HKeyLocalMachine RootKey, you can specify the registry key SOFTWARE\Microsoft\CCM.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-RegistryOperator

Use this parameter to specify the operator for the task sequence to evaluate the registry value. If you use the Exists or NotExists values, then you don't need to use the RegistryValueData parameter.

Type:VariableOperatorType
Accepted values:Exists, NotExists, Equals, NotEquals, Greater, GreaterEqual, Less, LessEqual
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-RegistryValueData

If you use a comparative RegistryOperator like Equals, use this parameter to specify the value data to evaluate. Use ValueType to specify the registry type.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RegistryValueName

Specify the name of the registry value to check. If you don't specify this parameter, the condition checks the (Default) value of the specified RegistryKey.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RootKey

Specify the registry root key to check.

Type:RegistryRootKeyType
Accepted values:HKeyCurrentUser, HKeyLocalMachine, HKeyUsers, HKeyCurrentConfig
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ValueType

Specify the type of registry value to check. Use this parameter with the RegistryValueData to specify the value data.

Type:RegistryValueType
Accepted values:RegistrySZ, RegistryExpandSZ, RegistryDWord
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet doesn't run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

IResultObject

Notes

For more information on this return object and its properties, see SMS_TaskSequence_RegistryConditionExpression server WMI class.