Windows Vista Forums

Why is Out-Default required here?
  1. #1


    Hans Dingemans Guest

    Why is Out-Default required here?

    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


      My System SpecsSystem Spec

  2. #2


    Wolfgang Kais Guest

    Re: Why is Out-Default required here?

    Hello Hans.

    Hans Dingemans wrote:

    > 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.
    The first pipeline returns a Selected.System.Diagnostics.Process object,
    the second one returns special formatting object. All of these objects
    are passed down the script pipeline which only consists of the call of
    the script, so all returned objects have to be displayed somehow. It
    seems that the formatting objects can't be "displayed" together with
    other objects.

    > When I explicitly pipe the first statement to Out-Default, it works
    > just fine from the script too.
    Out-Default performs default formatting and sends the objects to the
    host (Out-Host), so the selected process will not be returned in the
    script pipeline, so there is no conflict with the formatting objects
    when the objects returned by the script are to be displayed.

    --
    Kind regards,
    Wolfgang



      My System SpecsSystem Spec

  3. #3


    Larry__Weiss Guest

    Re: Why is Out-Default required here?

    It has to do with putting dissimilar objects in the pipeline
    and then having a formatter try to deal with them.

    See the two comments by Don Jones at
    http://www.minasi.com/forum/topic.as...D=20456#103477

    These incident reports have been opened on this topic

    https://connect.microsoft.com/PowerS...un-in-sequence

    https://connect.microsoft.com/PowerS...ault-formatter

    https://connect.microsoft.com/PowerS...peline#details

    - Larry

    On 5/20/2010 6:21 AM, Hans Dingemans wrote:

    > 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

      My System SpecsSystem Spec

  4. #4


    Hans Dingemans Guest

    Re: Why is Out-Default required here?

    Thanx to both Wolfgang and Larry!

    Useful info :-)

    "Hans Dingemans" <hansdingemans@newsgroup> schreef in bericht
    news:eoP##5A#KHA.1888@newsgroup

    > 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

      My System SpecsSystem Spec

Why is Out-Default required here? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Programs - Program Default Associations Brink Tutorials 67 05 Oct 2010
Vista - default printer doesn't stay as default Freddie Kang Vista print fax & scan 15 18 Apr 2010
Re: vista ultimate 64-bit default programs and IE7 default email p PA Bear [MS MVP] Vista mail 6 10 Oct 2008
Vista keeps stealing default status from default printer computer e.t. Vista networking & sharing 0 21 Aug 2007
RE: Default Users/My User location, is it possible to move the default to D:/ drive? William Topping Vista General 2 08 Oct 2006