Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
January 9, 2024

Taking Care of the Environment

We all know that PowerShell is based on the .NET Framework. PowerShell exposes a lot of the framework through abstractions like cmdlets and providers. Microsoft never wanted to force IT Pros to be .NET developers to use PowerShell. However, a little .NET experience can go a long way, and there may be situations where invoking the .NET framework is the best or only solution.

One area where you might need a .NET solution is with the environment. I’m talking about your computer environment, which we’ve had since the days of DOS.

C:\> set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Jeff\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=PROSPERO
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData                                                                                                                                                                                                                                                                                                                                                                                  HOMEDRIVE=C:
HOMEPATH=\Users\Jeff
LOCALAPPDATA=C:\Users\Jeff\AppData\Local
LOGONSERVER=\\PROSPERO
NUMBER_OF_PROCESSORS=20
...

In PowerShell, these items are exposed with the ENV: PSDrive.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.