New-CMTSStepConditionSoftware

Create an installed software condition for a task sequence step.

Syntax

New-CMTSStepConditionSoftware
   [-IsAnyVersion <Boolean>]
   -MsiFilePath <String>
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Use this cmdlet to create an installed software 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 a condition object for the Configuration Manager console MSI.

It then uses the Set-CMTSStepRunPowerShellScript cmdlet to add this condition object to the Run PowerShell Script step of the Default OS deployment task sequence.

$msi = "\\cm01.contoso.com\SMS_XYZ\bin\i386\adminconsole.msi"

$condition = New-CMTSStepConditionSoftware -MsiFilePath $msi -IsAnyVersion $true

$tsNameOsd = "Default OS deployment"
$tsStepNameRunPwsh = "Run PowerShell Script"

Set-CMTSStepRunPowerShellScript -TaskSequenceName $tsNameOsd -StepName $tsStepNameRunPwsh -AddCondition $condition

This sample script creates the following condition on the step:

Software An version of "Microsoft Endpoint Configuration Manager Console" installed

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

-IsAnyVersion

Use this parameter to determine how the condition matches the MSI codes:

  • $true: Match any version of this product, MSI upgrade code only
  • $false: Match this specific product, MSI product code and upgrade code

If you don't specify this parameter, by default it matches the specific product.

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

-MsiFilePath

Specify the path to the MSI file to evaluate. The cmdlet reads the product details from this MSI. The path to the MSI isn't saved, just the product details.

For example, it saves the following details for the Configuration Manager version 2107 AdminConsole.msi:

  • ProductCode: {B3842C82-95EB-472C-940A-D82C4A10857D}
  • ProductName: Microsoft Endpoint Configuration Manager Console
  • UpgradeCode: {B038D5E8-6C93-4A05-9E21-240324CFDF0E}
  • Version: 5.2107.1059.1000
Type:String
Position:Named
Default value:None
Required:True
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_SoftwareConditionExpression server WMI class.