Removes an environment variable.
Remove-EnvironmentVariable -Name <String> -ForProcess [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-EnvironmentVariable -Name <String> -ForUser [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-EnvironmentVariable -Name <String> -ForComputer [-WhatIf] [-Confirm] [<CommonParameters>]
Uses the .NET Environment class to remove an environment variable from the Process, User, or Computer scopes.
Changes to environment variables in the User and Machine scope are not picked up by running processes. Any running processes that use this environment variable should be restarted.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Name | String | The environment variable to remove. |
true | false | |
ForProcess | SwitchParameter | Removes the environment variable for the current process. |
true | false | False |
ForUser | SwitchParameter | Removes the environment variable for the current user. |
true | false | False |
ForComputer | SwitchParameter | Removes the environment variable for the current computer. |
true | false | False |
WhatIf | SwitchParameter | false | false | ||
Confirm | SwitchParameter | false | false | ||
CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters . |
Remove-EnvironmentVariable -Name 'MyEnvironmentVariable' -ForProcess
Removes the MyEnvironmentVariable
from the process scope.