Edit

Share via


New-CMTSStepConditionFolder

Create a folder properties condition for a task sequence step.

Syntax

Default (Default)

New-CMTSStepConditionFolder
    [-FolderDateTimeOperator <VariableOperatorType>]
    -FolderPath <String>
    [-FolderTimestamp <DateTime>]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Use this cmdlet to create a folder properties 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.

There are two types of checks that you can do with this condition:

  • To check if the folder exists, use the required FolderPath parameter.
  • To also check the folder timestamp, use the FolderTimestamp and FolderDateTimeOperator parameters.

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 checks for the existence and timestamp for the Configuration Manager PowerShell module help file folder. It creates a condition object for the folder and that its timestamp is greater than August 2, 2021.

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.

$folder = "C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\en-US"
$datetime = Get-Date ("August 2, 2021")

$condition = New-CMTSStepConditionFolder -FolderPath $folder -FolderTimestamp $datetime -FolderDateTimeOperator Greater

$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:

Folder C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\en-US exists and timestamp greater than "8/1/2021 16:00:00"

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

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

-DisableWildcardHandling

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

Parameter properties

Type:SwitchParameter
Default value:None
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

-FolderDateTimeOperator

When you use the FolderTimestamp parameter, use this parameter to specify the operator for the task sequence to evaluate the folder's timestamp.

Parameter properties

Type:VariableOperatorType
Default value:None
Accepted values:Equals, NotEquals, Greater, GreaterEqual, Less, LessEqual
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

-FolderPath

Specify the full path of the folder for this condition.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-FolderTimestamp

To evaluate the folder's timestamp, use this parameter to specify a datetime object. To get this object, use the built-in Get-Date cmdlet.

Then use the FolderDateTimeOperator parameter to set the evaluation operator.

Parameter properties

Type:DateTime
Default value:None
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

-ForceWildcardHandling

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

Parameter properties

Type:SwitchParameter
Default value:None
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

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

IResultObject

Notes

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