CmdID / PowerShell / Cmdlets / Remove
Remove-Variable
Deletes a variable and its value. PowerShell reference
From the PowerShell reference
7 parameters
Alias rv
What it does
Deletes a variable and its value. 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.
Remove-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude <String[]>] [-Force] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove a variable
Remove-Variable SmpIdentifyIts page in the reference: Remove-Variable.
Parameters
-ExcludeSpecifies 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.-ForceIndicates that the cmdlet removes a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.-IncludeSpecifies 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.-NameSpecifies the name of the variable to be removed. The parameter name (Name) is optional. Wildcards are permitted-ScopeGets only the variables in the specified scope. The acceptable values for this parameter are:
- Global
- Local
- Script
- A number relative to the current scope (0 through the number of scopes, where 0 is the current
scope and 1 is its parent)
Local is the default. For more information, see about_Scopes.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.