Skip to main content
TopMiniSite

Back to all posts

How to Set $Env:path In Powershell?

Published on
2 min read
How to Set $Env:path In Powershell? image

Best PowerShell Environment Path Tools to Buy in November 2025

1 Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

BUY & SAVE
$47.34 $59.99
Save 21%
Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
2 Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS

Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS

BUY & SAVE
$39.49
Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS
3 Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

BUY & SAVE
$0.99
Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects
4 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$32.98 $44.99
Save 27%
Learn Windows PowerShell in a Month of Lunches
5 PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms

PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms

BUY & SAVE
$47.49 $49.99
Save 5%
PowerShell for Penetration Testing: Explore the capabilities of PowerShell for pentesters across multiple platforms
6 PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)

PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)

BUY & SAVE
$37.95
PowerShell Advanced Cookbook: Enhance your scripting skills and master PowerShell with 90+ advanced recipes (English Edition)
7 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$40.91 $44.99
Save 9%
Learn Windows PowerShell in a Month of Lunches
8 Learn PowerShell Toolmaking in a Month of Lunches

Learn PowerShell Toolmaking in a Month of Lunches

BUY & SAVE
$53.45
Learn PowerShell Toolmaking in a Month of Lunches
9 Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts

Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts

BUY & SAVE
$26.99 $59.99
Save 55%
Troubleshooting SharePoint: The Complete Guide to Tools, Best Practices, PowerShell One-Liners, and Scripts
+
ONE MORE?

To set the $env:path variable in PowerShell, you can use the following command:

$env:path = "C:\path\to\directory;$env:path"

Replace "C:\path\to\directory" with the directory path you want to add to the $env:path variable. This command will append the specified directory to the end of the existing $env:path variable.

What is the default value of $env:path in Powershell?

The default value of the $env:path variable in Powershell is the system PATH environment variable, which contains a list of directories where the operating system looks for executable files.

How to add environment variables to $env:path in Powershell?

To add environment variables to $env:path in Powershell, you can use the following command:

$env:Path += ";C:\path\to\your\new\directory"

Replace "C:\path\to\your\new\directory" with the actual path to the directory you want to add to the $env:path variable. This command appends the specified directory to the existing $env:path variable.

How to revert changes made to $env:path in Powershell?

To revert changes made to the $env:path variable in Powershell, you can either:

  1. Close and reopen the Powershell session: When you close the current Powershell session and open a new one, the $env:path variable will be reset to its original state.
  2. Reset the $env:path variable manually: You can reset the $env:path variable manually using the following command: $env:path = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
  3. Set the $env:path variable to its original value: If you know the original value of the $env:path variable, you can set it back using the following command: $env:path = "original-path-value"

By using any of these methods, you can revert changes made to the $env:path variable in Powershell.