Remove-Variable
Deletes a variable and its value.
Sintassi
Default (impostazione predefinita).
Remove-Variable
[-Name] <String[]>
[-Include <String[]>]
[-Exclude <String[]>]
[-Force]
[-Scope <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Descrizione
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.
Esempio
Example 1: Remove a variable
Remove-Variable Smp
This command deletes the $Smp
variable.
Parametri
-Confirm
Prompts you for confirmation before running the cmdlet.
Proprietà dei parametri
Tipo: | SwitchParameter |
Valore predefinito: | False |
Supporta i caratteri jolly: | False |
DontShow: | False |
Alias: | cf |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | False |
-Exclude
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.
Proprietà dei parametri
Tipo: | String[] |
Valore predefinito: | None |
Supporta i caratteri jolly: | True |
DontShow: | False |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | False |
-Force
Indicates that the cmdlet removes a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.
Proprietà dei parametri
Tipo: | SwitchParameter |
Valore predefinito: | None |
Supporta i caratteri jolly: | False |
DontShow: | False |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | False |
-Include
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.
Proprietà dei parametri
Tipo: | String[] |
Valore predefinito: | None |
Supporta i caratteri jolly: | True |
DontShow: | False |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | False |
-Name
Specifies the name of the variable to be removed. The parameter name (Name) is optional. Wildcards are permitted
Proprietà dei parametri
Tipo: | String[] |
Valore predefinito: | None |
Supporta i caratteri jolly: | True |
DontShow: | False |
Set di parametri
(All)
Posizione: | 0 |
Obbligatorio: | True |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | True |
Valore dagli argomenti rimanenti: | False |
-Scope
Gets 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.
Proprietà dei parametri
Tipo: | String |
Valore predefinito: | None |
Supporta i caratteri jolly: | False |
DontShow: | False |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Proprietà dei parametri
Tipo: | SwitchParameter |
Valore predefinito: | False |
Supporta i caratteri jolly: | False |
DontShow: | False |
Alias: | wi |
Set di parametri
(All)
Posizione: | Named |
Obbligatorio: | False |
Valore dalla pipeline: | False |
Valore dalla pipeline in base al nome della proprietà: | False |
Valore dagli argomenti rimanenti: | 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.
Input
PSVariable
You can pipe a variable object to this cmdlet.
Output
None
This cmdlet returns no output.
Note
PowerShell includes the following aliases for Remove-Variable
:
All platforms:
rv
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.