Remove-CMDeviceCollectionVariable
Remove a device collection variable.
Syntax
SearchByValueMandatory (Default)
Remove-CMDeviceCollectionVariable
-Collection <IResultObject>
-VariableName <String>
[-Force]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SearchByIdMandatory
Remove-CMDeviceCollectionVariable
-CollectionId <String>
-VariableName <String>
[-Force]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SearchByNameMandatory
Remove-CMDeviceCollectionVariable
-CollectionName <String>
-VariableName <String>
[-Force]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Use this cmdlet to remove a device collection variable.
Default collections can't have variables. Any collection that you target should have an ID that starts with the site code, not SMS
.
For more information, see How to set task sequence variables.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>
. For more information, see getting started.
Examples
Example 1: Remove a device collection variable
The first command gets the device collection object named Device and stores it in the $Collection variable.
The second command removes the device collection variable named testTS from the device collection stored in the $Collection variable. Specifying the Force parameter indicates that you aren't prompted before the variable is removed.
$Collection = Get-CMCollection -Name "Device"
Remove-CMDeviceCollectionVariable -Collection $Collection -VariableName "testTS" -Force
Example 2: Remove all variables from a device collection
This example first uses the Get-CMDeviceCollectionVariable cmdlet to get all variables on the device collection IT Servers and stores the objects in the vars array variable. It then loops through each item in the array, and removes the variable by name.
The Force parameter is used so that you're not prompted to remove each variable.
$collName = "IT servers"
$vars = Get-CMDeviceCollectionVariable -CollectionName $collName
foreach ( $var in $vars ) {
Remove-CMDeviceCollectionVariable -CollectionName $collName -VariableName $var -Force
}
Since the VariableName parameter doesn't allow wildcards, use this process if you need to quickly clear all variables from a device collection.
Parameters
-Collection
Specify a device collection object to remove its variables. To get this object, use the Get-CMCollection or Get-CMDeviceCollection cmdlets.
Parameter properties
Type: | IResultObject |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
SearchByValueMandatory
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-CollectionId
Specify the ID of a device collection to remove its variables. This value is the CollectionID property, for example, XYZ00012
. Since you can't set variables on default collections, this value starts with the site code, not SMS
.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
SearchByIdMandatory
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-CollectionName
Specify the name of a device collection to remove its variables.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
SearchByNameMandatory
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
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 |
-Force
Forces the command to run without asking for user confirmation.
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 |
-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 |
-VariableName
Specify the name of a collection variable to remove. This parameter doesn't accept wildcard characters.
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 |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
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.