New-CMTSStepConditionFile
Create a file properties condition for a task sequence step.
Syntax
Default (Default)
New-CMTSStepConditionFile
[-FileDateTimeOperator <VariableOperatorType>]
-FilePath <String>
[-FileTimestamp <DateTime>]
[-FileVersion <String>]
[-VersionOperator <VariableOperatorType>]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Use this cmdlet to create a file 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 three types of checks that you can do with this condition:
- To check if the file exists, use the required FilePath parameter.
- To also check the file version, use the FileVersion and VersionOperator parameters.
- To also check the file timestamp, use the FileTimestamp and FileDateTimeOperator 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 one of the Configuration Manager PowerShell module help files. It creates a file condition object for the file 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.
$file = "C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\en-US\AdminUI.PS.dll-Help.xml"
$datetime = Get-Date ("August 2, 2021")
$condition = New-CMTSStepConditionFile -FilePath $file -FileTimestamp $datetime -FileDateTimeOperator 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:
File C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\en-US\AdminUI.PS.dll-Help.xml 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 |
-FileDateTimeOperator
When you use the FileTimestamp parameter, use this parameter to specify the operator for the task sequence to evaluate the file'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 |
-FilePath
Specify the full path including the name of the file 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 |
-FileTimestamp
To evaluate the file's timestamp, use this parameter to specify a datetime object. To get this object, use the built-in Get-Date cmdlet.
Then use the FileDateTimeOperator 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 |
-FileVersion
To evaluate the file's version, use this parameter to specify the version string.
Then use the VersionOperator parameter to set the evaluation operator.
Parameter properties
Type: | String |
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 |
-VersionOperator
When you use the FileVersion parameter, use this parameter to specify the operator for the task sequence to evaluate the file's version.
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 |
-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_FileConditionExpression server WMI class.