Remove-CMDeviceCollectionVariable
Remove a device collection variable.
Syntax
Remove-CMDeviceCollectionVariable
-Collection <IResultObject>
[-Force]
-VariableName <String>
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-CMDeviceCollectionVariable
-CollectionId <String>
[-Force]
-VariableName <String>
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-CMDeviceCollectionVariable
-CollectionName <String>
[-Force]
-VariableName <String>
[-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.
Type: | IResultObject |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | 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
.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CollectionName
Specify the name of a device collection to remove its variables.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
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 |
-Force
Forces the command to run without asking for user confirmation.
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 |
-VariableName
Specify the name of a collection variable to remove. This parameter doesn't accept wildcard characters.
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: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.ConfigurationManagement.ManagementProvider.IResultObject
Outputs
System.Object