03 Jul 2013 @ 8:21 AM 

When you use the Get-Variable cmdlet you’ll get a list of variables available in PowerShell.
This does not include the environment variables which are available on the Windows OS though, only the ones native to PowerShell.

One that is not included in this list, but is very much available in PowerShell is the $Env.

## Update thanks to Aleksandar Nikolic ##
The reason why this is not included in the list with variables is because it isn’t a variable; it’s a PSDrive.
You can find the PSDrives with the Get-PSDrive cmdlet.
## End of update ##

This allows you to call environment variables from PowerShell, and use them… like so:

PS C:\Users\Jeff> $Env:Windir
C:\Windows

An example that may be more familiar to you would be the computer name:

PS C:\Users\Jeff> $Env:ComputerName
MINIMONSTER
Posted By: Jeff Wouters
Last Edit: 03 Jul 2013 @ 09:15 AM

EmailPermalink
Tags
Categories: DuPSUG, PowerShell



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 339
  • Comments » 486
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.

Speaking



    No Child Pages.

Health Check



    No Child Pages.