Equivalent of Python Virtual Environment in PowerShell

Long time PowerShell user, and I have been doing a bit study of Python.

One of the things that intrigued me was the use of virtual environments, venv. In a nutshell it creates a sandbox environment which you can load up older version of Python or any other modules that you want to pull. Once you have what you need or download the module you can ‘freeze’ it and output as a ‘requirements.txt’ file. We can then create a new venv and use the same requirements.txt to download the same set up again.

I like the idea because I can run modules in an isolated manner.

I am just wondering whether PowerShell has anything like this? I would love to use something like this.


If the purpose is to have a restricted environment you can look at custom pssession configurations. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_session_configurations?view=powershell-7 also referred to as “JEA” - just enough administration.

JEA is different. It’s purpose is security. It also works against remote endpoints as oppose to local.

Venv is used to isolate modules to versions. I could have different versions of a modules on the system but venv allows me to sandbox to particular ones