506528 (1) [Avatar] Offline
#1
Hello!

In chapter 10, page 132 in the Above and Beyond section it suggests to enter:
Get-Process |
Format-Table Name,
@{name='VM(MB)';expression={$_.VM / 1 MB -as [int]}} -autosize

It says that after you hit enter on the first line Powershell changes its prompt and waits for more commands, however I can't get past that first line, it just throws an error saying 'An empty pipe element is not allowed'. How do I resolve this? It would be very nice to be able to enter commands over multiple lines rather than sometimes super duper long one-line commands
502470 (1) [Avatar] Offline
#2
Hi there

I've just come across this myself - it appears that this will only work in the standard Powershell window - if you're using the Powershell ISE window (which is, ironically, pushed and recommended all the way through the book!) it will fail with the Empty Pipe error.

According to some Stack Overflow research, the reason is apparently: "Powershell ISE ( integrated scripting environment ) is not the standard Powershell console. The ISE, like the name suggests, is a pretty basic GUI based script writing tool and doesn't support interactive console applications"

I hope that helps!

Cheers

Steve
Lee_Dailey (4) [Avatar] Offline
#3
howdy y'all,

the code posted in the OP works for me after i remove the space between the `1` and the `MB`. [*grin*] while the structure used is less readable than i care for, it _is_ valid code as long as there is no invisible stuff after the pipe.

take care,
lee