New-CMTSStepConditionFolder
Create a folder properties condition for a task sequence step.
Syntax
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.
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 |
-FolderDateTimeOperator
When you use the FolderTimestamp parameter, use this parameter to specify the operator for the task sequence to evaluate the folder's timestamp.
Type: | VariableOperatorType |
Accepted values: | Equals, NotEquals, Greater, GreaterEqual, Less, LessEqual |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-FolderPath
Specify the full path of the folder for this condition.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | DateTime |
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 |
-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_FolderConditionExpression server WMI class.