23

PowerShell displays environment variables, one line for each. If a variable has a long enough value, it is truncated, and appended an ellipsis:

> gci env:

Name                           Value
----                           -----
<suppressed lines>
PSModulePath                   C:\Windows\system32\WindowsPowerSh...
<suppressed lines>

Is there any way of obtaining full values for all vars at once, as in a standard cmd prompt? (the answers given for Powershell get-childitem env:path returns ellipsed one line, how to have something useful? would not apply, then).

1
  • 1
    I've spent an hour on searching for ways to get PowerShell to display the complete content of my path environment variable. It always truncates it to 2452 characters, with or without ellipsis marks, even if I specify wider formatting. This makes it impossible to treat PS as anything other than trivially useful. My opinion of PS is that it's a POS and nothing has changed that. I've read through hundreds of blogs and search results and nobody has a solution. Not even here.
    – Suncat2000
    Commented Jun 21, 2017 at 13:11

2 Answers 2

30

Default formatting truncates, specify -Wrap and see full output.

gci env: | Format-Table -Wrap -AutoSize

Result

PSModulePath            C:\Users\KNUCKLE-DRAGGER\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

or if you prefer the output to exactly simulate cmd.exe, try

cmd /c start /b set

Result

PSModulePath=C:\Users\KNUCKLE-DRAGGER\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
3
  • This is already very good. Any way of getting the same format as a standard cmd prompt? Perhaps invoking cmd.exe from the PowerShell prompt? Commented Dec 18, 2013 at 17:56
  • Good, that's what I was proposing. Commented Dec 18, 2013 at 18:02
  • 1
    Do PowerShell Users Actually Type EveryThing Using Mixed Case? Because it seems to work fine without all that shift-key prodding. Are there any situations where mixed case is mandatory?
    – Ed Randall
    Commented Jul 14, 2020 at 6:59
5

If you want to emulate set output from powershell without invoking cmd try:

dir env: | %{"{0}={1}" -f $_.Name,$_.Value}

a lot of typing, so wrap it in a function:

function set {dir env: | %{"{0}={1}" -f $_.Name,$_.Value}}
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .