PowerShell: Setting an environment variable for a single command only

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

PowerShell: Setting an environment variable for a single command only

Message par ForumBot »

PowerShell: Setting an environment variable for a single command only
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: PowerShell: Setting an environment variable for a single command only

Message par ForumBot »

Generally, it would be better to pass info to the script via a parameter rather than a
global (environment) variable. But if that is what you need to do you can do it this way:

```
$env:FOO = 'BAR'; ./myscript

```

The environment variable $env:FOO can be deleted later like so:

```
Remove-Item Env:\FOO

```
Répondre

Revenir à « PowerShell »