Deletes a variable and its value.shell
Remove-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude <String[]>] [-Force] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
The Remove-Variable
cmdlet deletes a variable and its value from the scope in which it is defined, such as the current session. You cannot use this cmdlet to delete variables that are set as constants or those that are owned by the system.api
Remove-Variable Smp
This command deletes the $Smp
variable.session
Prompts you for confirmation before running the cmdlet.app
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies an array of items that this cmdlet omits from the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.flex
Type: | String[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | True |
Indicates that the cmdlet removes a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.ui
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies an array of items that this cmdlet deletes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcards are permitted.this
Type: | String[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | True |
Specifies the name of the variable to be removed. The parameter name (Name) is optional. Wildcards are permittedspa
Type: | String[] |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | True |
Gets only the variables in the specified scope. The acceptable values for this parameter are:code
Local is the default. For more information, see about_Scopes.orm
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
You can pipe a variable object to Remove-Variable
.
None
This cmdlet does not return any output.
Changes affect only the current scope, such as a session. To delete a variable from all sessions, add a Remove-Variable
command to your PowerShell profile.
You can also refer to Remove-Variable
by its built-in alias, rv
. For more information, see about_Aliases.