What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For the ordinary cmd.exe command set NAME=value, use PowerShell’s environment-variable syntax:
$Env:NAME = 'value'
Read it with $Env:NAME, list the current process environment with Get-ChildItem Env:, and remove it with $Env:NAME = $null or Remove-Item Env:NAME. Do not confuse $Env:NAME with $name: the former is an environment variable inherited by child processes, while the latter is an ordinary PowerShell variable.
Basic set equivalents
| cmd.exe operation | PowerShell equivalent | What it does |
|---|---|---|
set |
Get-ChildItem Env: |
Lists environment variables in the current process. |
set NAME |
Get-ChildItem Env:NAME* |
Finds variables whose names begin with NAME; the wildcard makes the prefix match explicit. |
| Read one value | $Env:NAME |
Returns the value as a string. |
set NAME=value |
$Env:NAME = 'value' |
Sets a value for the current PowerShell process. |
set NAME= |
$Env:NAME = $null or Remove-Item Env:NAME |
Removes the variable. Empty-string behavior is version-dependent. |
Listing and reading variables
# List the current process environment
Get-ChildItem Env:
# Read one variable
$Env:Path
# Prefix-style lookup, similar to cmd.exe's "set NAME"
Get-ChildItem Env:Path*
PowerShell exposes environment variables through the Env: provider. The item-style equivalents are Get-Item Env:NAME, Set-Item Env:NAME 'value', and Remove-Item Env:NAME.
Assigning and removing a value
$Env:APP_MODE = 'development'
# Remove it from this process
Remove-Item Env:APP_MODE
# Equivalent removal form
$Env:APP_MODE = $null
These changes affect the current PowerShell process and processes it starts; they do not permanently rewrite Windows user or machine settings.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Book - powershell for sysadmins: workflow automation made easy
- Language: english
- Binding: paperback
Do not use an ordinary PowerShell variable by mistake
$name = 'value' # PowerShell-only variable
$Env:NAME = 'value' # Environment variable
$name is script data. A child program normally cannot see it. $Env:NAME is placed in the process environment, so a child process launched afterward can inherit it. Environment values are strings; convert other data types when assigning them.
Translate the other forms of set
Prompting with set /P
For a batch command such as set /P NAME=Prompt, prompt with Read-Host and assign the result to the environment variable:
$Env:USERNAME_INPUT = Read-Host 'Enter a name'
This is a behavior-level equivalent, not identical parser compatibility. Read-Host returns the entered text, which is then available to child processes through $Env:USERNAME_INPUT.
Arithmetic with set /A
Use a normal PowerShell expression rather than copying cmd.exe’s arithmetic syntax:
Rank #3
$count = 4 + 5
If another process needs the result as an environment string, convert it explicitly:
$Env:COUNT = $count.ToString()
cmd.exe arithmetic has its own conventions, including hexadecimal values with 0x and leading-zero octal notation. Review such expressions instead of assuming they have the same meaning in PowerShell.
Rank #4
Expansion, quoting, and special characters
Variable expansion
Batch files commonly expand a value as %NAME%. PowerShell uses $Env:NAME in expressions and expandable double-quoted strings:
"
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
Does $name = 'value' replace set NAME=value?
No. $name creates an ordinary PowerShell variable. Use $Env:NAME = 'value' when the value must be an environment variable visible to child processes.
Recommended Free Tools
Best Value
How do I make an environment-variable change permanent?
Use Windows User or Machine scope through System.Environment.SetEnvironmentVariable() or the Environment Variables control panel. A persistent change generally affects processes launched later, not shells that are already running.
The Bottom Line
Use $Env:NAME = 'value' for the normal set NAME=value translation. Handle listing, prompting, arithmetic, deletion, and persistence separately because each has different PowerShell semantics.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

