H
Hans Dingemans
gps | select name, vm, @{name='MB';expression={[int]($_.vm/1mb)}} -first 1
gps | select -first 1 | ft name, vm,
@{label='MB';e={[int]($_.vm/1mb)}} -autosize
The above two statements work just fine when entered via keyboard. If you
put them in a .ps1 script file I get an error and the second pipe is not
executed.
PS> .\test.ps1
Name VM
MB
---- --
--
AcroRd32 165748736
158
out-lineoutput : The object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid
or not in the correct sequence. This is likely caused by a user-specified
"format-table" command which is conflicting with the default formatting.
+ CategoryInfo : InvalidData: (
[out-lineoutput],
InvalidOperation Exception
+ FullyQualifiedErrorId :
ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
PS>
When I explicitly pipe the first statement to Out-Default, it works just
fine from the script too.
gps | select name, vm, @{name='MB';expression={[int]($_.vm/1mb)}} -first 1 |
Out-Default # <===
gps | select -first 1 | ft name, vm,
@{label='MB';e={[int]($_.vm/1mb)}} -autosize
How come?
Thanx for any reaction,
Hans Dingemans
gps | select -first 1 | ft name, vm,
@{label='MB';e={[int]($_.vm/1mb)}} -autosize
The above two statements work just fine when entered via keyboard. If you
put them in a .ps1 script file I get an error and the second pipe is not
executed.
PS> .\test.ps1
Name VM
MB
---- --
--
AcroRd32 165748736
158
out-lineoutput : The object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid
or not in the correct sequence. This is likely caused by a user-specified
"format-table" command which is conflicting with the default formatting.
+ CategoryInfo : InvalidData: (

InvalidOperation Exception
+ FullyQualifiedErrorId :
ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
PS>
When I explicitly pipe the first statement to Out-Default, it works just
fine from the script too.
gps | select name, vm, @{name='MB';expression={[int]($_.vm/1mb)}} -first 1 |
Out-Default # <===
gps | select -first 1 | ft name, vm,
@{label='MB';e={[int]($_.vm/1mb)}} -autosize
How come?
Thanx for any reaction,
Hans Dingemans