external help file | Module Name | ms.date | schema | title |
---|---|---|---|---|
AdminUI.PS.dll-Help.xml |
ConfigurationManager |
12/29/2021 |
2.0.0 |
Remove-CMDeviceCollectionVariable |
Remove a device collection variable.
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>]
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.
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
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.
Specify a device collection object to remove its variables. To get this object, use the Get-CMCollection or Get-CMDeviceCollection cmdlets.
Type: IResultObject
Parameter Sets: SearchByValueMandatory
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
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
Parameter Sets: SearchByIdMandatory
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the name of a device collection to remove its variables.
Type: String
Parameter Sets: SearchByNameMandatory
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Forces the command to run without asking for user confirmation.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the name of a collection variable to remove. This parameter doesn't accept wildcard characters.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Get-CMDeviceCollectionVariable New-CMDeviceCollectionVariable Set-CMDeviceCollectionVariable