20

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
    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 Jun 21 '17 at 13:11
27

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\
| improve this answer | |
  • 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? – sancho.s ReinstateMonicaCellio Dec 18 '13 at 17:56
  • Good, that's what I was proposing. – sancho.s ReinstateMonicaCellio Dec 18 '13 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 Jul 14 at 6:59
4

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}}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.