Windows Vista Forums

Format-List Issue
  1. #1


    Per Moeller-Olsen Guest

    Format-List Issue

    When I run this in PowerShell:

    Get-Date

    Get-EventLog security -newest 1 | Format-List

    I get this error:



    out-lineoutput : Object of type
    "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
    or not in the correct sequence.
    This is likely caused by a user-specified "format-list" command which is
    conflicting with the default formatting.

    When I just run this:

    Get-EventLog security -newest 1 | Format-List

    no problem.

    It is as if Get-Date modifies something when it comes to Format-List. It's
    not only Get-Date that does it, commands like Get-Process and Get-Host do
    the same thing.

    How do I work around this problem?

    Per...




      My System SpecsSystem Spec

  2. #2


    Shay Levi Guest

    Re: Format-List Issue



    I exceuted it on both v1 and v2 and didn't get any error.

    What do you mean by run it? I copied the following and pasted it into the
    console:

    > Get-Date
    >
    > Get-EventLog security -newest 1 | Format-List
    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com

    > When I run this in PowerShell:
    >
    > Get-Date
    >
    > Get-EventLog security -newest 1 | Format-List
    >
    > I get this error:
    >
    > out-lineoutput : Object of type
    > "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    > legal
    > or not in the correct sequence.
    > This is likely caused by a user-specified "format-list" command which
    > is
    > conflicting with the default formatting.
    > When I just run this:
    >
    > Get-EventLog security -newest 1 | Format-List
    >
    > no problem.
    >
    > It is as if Get-Date modifies something when it comes to Format-List.
    > It's not only Get-Date that does it, commands like Get-Process and
    > Get-Host do the same thing.
    >
    > How do I work around this problem?
    >
    > Per...
    >


      My System SpecsSystem Spec

  3. #3


    RichS Guest

    RE: Format-List Issue

    I cannot reproduce this error. What version of PowerShell and what operating
    system are you using?
    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Per Moeller-Olsen" wrote:

    > When I run this in PowerShell:
    >
    > Get-Date
    >
    > Get-EventLog security -newest 1 | Format-List
    >
    > I get this error:
    >
    > out-lineoutput : Object of type
    > "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
    > or not in the correct sequence.
    > This is likely caused by a user-specified "format-list" command which is
    > conflicting with the default formatting.
    >
    > When I just run this:
    >
    > Get-EventLog security -newest 1 | Format-List
    >
    > no problem.
    >
    > It is as if Get-Date modifies something when it comes to Format-List. It's
    > not only Get-Date that does it, commands like Get-Process and Get-Host do
    > the same thing.
    >
    > How do I work around this problem?
    >
    > Per...
    >
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Per Moeller-Olsen Guest

    Re: Format-List Issue

    I have the commands

    Get-Date

    Get-EventLog security -newest 1 | Format-List

    in a file called c:\scripts\test100.ps1

    and this

    powershell.exe -noexit c:\scripts\test100.ps1

    in file c:\scripts\ps100.cmd

    I am running PowerShell version 1.0 on a XP SP2 box and on a SBS 2003 SP1
    box

    Per...


    "RichS" <RichS@xxxxxx> wrote in message
    news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx

    >I cannot reproduce this error. What version of PowerShell and what
    >operating
    > system are you using?
    > --
    > Richard Siddaway
    > Please note that all scripts are supplied "as is" and with no warranty
    > Blog: http://richardsiddaway.spaces.live.com/
    > PowerShell User Group: http://www.get-psuguk.org.uk
    >
    >
    > "Per Moeller-Olsen" wrote:
    >

    >> When I run this in PowerShell:
    >>
    >> Get-Date
    >>
    >> Get-EventLog security -newest 1 | Format-List
    >>
    >> I get this error:
    >>
    >> out-lineoutput : Object of type
    >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    >> legal
    >> or not in the correct sequence.
    >> This is likely caused by a user-specified "format-list" command which is
    >> conflicting with the default formatting.
    >>
    >> When I just run this:
    >>
    >> Get-EventLog security -newest 1 | Format-List
    >>
    >> no problem.
    >>
    >> It is as if Get-Date modifies something when it comes to Format-List.
    >> It's
    >> not only Get-Date that does it, commands like Get-Process and Get-Host do
    >> the same thing.
    >>
    >> How do I work around this problem?
    >>
    >> Per...
    >>
    >>
    >>
    >>


      My System SpecsSystem Spec

  5. #5


    Brandon [MVP] Guest

    Re: Format-List Issue

    To repro do this
    get-date;Get-Eventlog security -newest1 | format-list

    "RichS" <RichS@xxxxxx> wrote in message
    news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx

    >I cannot reproduce this error. What version of PowerShell and what
    >operating
    > system are you using?
    > --
    > Richard Siddaway
    > Please note that all scripts are supplied "as is" and with no warranty
    > Blog: http://richardsiddaway.spaces.live.com/
    > PowerShell User Group: http://www.get-psuguk.org.uk
    >
    >
    > "Per Moeller-Olsen" wrote:
    >

    >> When I run this in PowerShell:
    >>
    >> Get-Date
    >>
    >> Get-EventLog security -newest 1 | Format-List
    >>
    >> I get this error:
    >>
    >> out-lineoutput : Object of type
    >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    >> legal
    >> or not in the correct sequence.
    >> This is likely caused by a user-specified "format-list" command which is
    >> conflicting with the default formatting.
    >>
    >> When I just run this:
    >>
    >> Get-EventLog security -newest 1 | Format-List
    >>
    >> no problem.
    >>
    >> It is as if Get-Date modifies something when it comes to Format-List.
    >> It's
    >> not only Get-Date that does it, commands like Get-Process and Get-Host do
    >> the same thing.
    >>
    >> How do I work around this problem?
    >>
    >> Per...
    >>
    >>
    >>
    >>

      My System SpecsSystem Spec

  6. #6


    RichS Guest

    Re: Format-List Issue

    I put the lines in a script and recreated the result

    If I comment out the Get-date OR move the get-date after the get-eventlog
    line everything is fine

    using [System.DateTime]::Now instead of get-date generates the same result

    However I did get this to work

    Get-Date -format g

    Get-EventLog security -newest 1 | Format-list

    You could try experimenting with other values for the format

    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Brandon [MVP]" wrote:

    > To repro do this
    > get-date;Get-Eventlog security -newest1 | format-list
    >
    > "RichS" <RichS@xxxxxx> wrote in message
    > news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx

    > >I cannot reproduce this error. What version of PowerShell and what
    > >operating
    > > system are you using?
    > > --
    > > Richard Siddaway
    > > Please note that all scripts are supplied "as is" and with no warranty
    > > Blog: http://richardsiddaway.spaces.live.com/
    > > PowerShell User Group: http://www.get-psuguk.org.uk
    > >
    > >
    > > "Per Moeller-Olsen" wrote:
    > >

    > >> When I run this in PowerShell:
    > >>
    > >> Get-Date
    > >>
    > >> Get-EventLog security -newest 1 | Format-List
    > >>
    > >> I get this error:
    > >>
    > >> out-lineoutput : Object of type
    > >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    > >> legal
    > >> or not in the correct sequence.
    > >> This is likely caused by a user-specified "format-list" command which is
    > >> conflicting with the default formatting.
    > >>
    > >> When I just run this:
    > >>
    > >> Get-EventLog security -newest 1 | Format-List
    > >>
    > >> no problem.
    > >>
    > >> It is as if Get-Date modifies something when it comes to Format-List.
    > >> It's
    > >> not only Get-Date that does it, commands like Get-Process and Get-Host do
    > >> the same thing.
    > >>
    > >> How do I work around this problem?
    > >>
    > >> Per...
    > >>
    > >>
    > >>
    > >>
    >

      My System SpecsSystem Spec

  7. #7


    Per Moeller-Olsen Guest

    Re: Format-List Issue

    Thanks everyone.

    This modified ps1 file also works:

    get-date > c:\scripts\test100.log

    get-EventLog security -newest 1 | Format-List | Out-File
    c:\scripts\test100.log -append

    $a = get-content c:\scripts\test100.log

    write-output $a

    Per...

    "RichS" <RichS@xxxxxx> wrote in message
    news:05FCE94C-417D-48C0-B83F-BA6EAFB7B418@xxxxxx

    >I put the lines in a script and recreated the result
    >
    > If I comment out the Get-date OR move the get-date after the get-eventlog
    > line everything is fine
    >
    > using [System.DateTime]::Now instead of get-date generates the same result
    >
    > However I did get this to work
    >
    > Get-Date -format g
    >
    > Get-EventLog security -newest 1 | Format-list
    >
    > You could try experimenting with other values for the format
    >
    > --
    > Richard Siddaway
    > Please note that all scripts are supplied "as is" and with no warranty
    > Blog: http://richardsiddaway.spaces.live.com/
    > PowerShell User Group: http://www.get-psuguk.org.uk
    >
    >
    > "Brandon [MVP]" wrote:
    >

    >> To repro do this
    >> get-date;Get-Eventlog security -newest1 | format-list
    >>
    >> "RichS" <RichS@xxxxxx> wrote in message
    >> news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx

    >> >I cannot reproduce this error. What version of PowerShell and what
    >> >operating
    >> > system are you using?
    >> > --
    >> > Richard Siddaway
    >> > Please note that all scripts are supplied "as is" and with no warranty
    >> > Blog: http://richardsiddaway.spaces.live.com/
    >> > PowerShell User Group: http://www.get-psuguk.org.uk
    >> >
    >> >
    >> > "Per Moeller-Olsen" wrote:
    >> >
    >> >> When I run this in PowerShell:
    >> >>
    >> >> Get-Date
    >> >>
    >> >> Get-EventLog security -newest 1 | Format-List
    >> >>
    >> >> I get this error:
    >> >>
    >> >> out-lineoutput : Object of type
    >> >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    >> >> legal
    >> >> or not in the correct sequence.
    >> >> This is likely caused by a user-specified "format-list" command which
    >> >> is
    >> >> conflicting with the default formatting.
    >> >>
    >> >> When I just run this:
    >> >>
    >> >> Get-EventLog security -newest 1 | Format-List
    >> >>
    >> >> no problem.
    >> >>
    >> >> It is as if Get-Date modifies something when it comes to Format-List.
    >> >> It's
    >> >> not only Get-Date that does it, commands like Get-Process and Get-Host
    >> >> do
    >> >> the same thing.
    >> >>
    >> >> How do I work around this problem?
    >> >>
    >> >> Per...
    >> >>
    >> >>
    >> >>
    >> >>
    >>


      My System SpecsSystem Spec

  8. #8


    RichS Guest

    Re: Format-List Issue

    If you don't need the output in a file this will work

    Get-Date | Out-Default

    Get-EventLog security -newest 1 | Format-list

    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Per Moeller-Olsen" wrote:

    > Thanks everyone.
    >
    > This modified ps1 file also works:
    >
    > get-date > c:\scripts\test100.log
    >
    > get-EventLog security -newest 1 | Format-List | Out-File
    > c:\scripts\test100.log -append
    >
    > $a = get-content c:\scripts\test100.log
    >
    > write-output $a
    >
    > Per...
    >
    > "RichS" <RichS@xxxxxx> wrote in message
    > news:05FCE94C-417D-48C0-B83F-BA6EAFB7B418@xxxxxx

    > >I put the lines in a script and recreated the result
    > >
    > > If I comment out the Get-date OR move the get-date after the get-eventlog
    > > line everything is fine
    > >
    > > using [System.DateTime]::Now instead of get-date generates the same result
    > >
    > > However I did get this to work
    > >
    > > Get-Date -format g
    > >
    > > Get-EventLog security -newest 1 | Format-list
    > >
    > > You could try experimenting with other values for the format
    > >
    > > --
    > > Richard Siddaway
    > > Please note that all scripts are supplied "as is" and with no warranty
    > > Blog: http://richardsiddaway.spaces.live.com/
    > > PowerShell User Group: http://www.get-psuguk.org.uk
    > >
    > >
    > > "Brandon [MVP]" wrote:
    > >

    > >> To repro do this
    > >> get-date;Get-Eventlog security -newest1 | format-list
    > >>
    > >> "RichS" <RichS@xxxxxx> wrote in message
    > >> news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx
    > >> >I cannot reproduce this error. What version of PowerShell and what
    > >> >operating
    > >> > system are you using?
    > >> > --
    > >> > Richard Siddaway
    > >> > Please note that all scripts are supplied "as is" and with no warranty
    > >> > Blog: http://richardsiddaway.spaces.live.com/
    > >> > PowerShell User Group: http://www.get-psuguk.org.uk
    > >> >
    > >> >
    > >> > "Per Moeller-Olsen" wrote:
    > >> >
    > >> >> When I run this in PowerShell:
    > >> >>
    > >> >> Get-Date
    > >> >>
    > >> >> Get-EventLog security -newest 1 | Format-List
    > >> >>
    > >> >> I get this error:
    > >> >>
    > >> >> out-lineoutput : Object of type
    > >> >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
    > >> >> legal
    > >> >> or not in the correct sequence.
    > >> >> This is likely caused by a user-specified "format-list" command which
    > >> >> is
    > >> >> conflicting with the default formatting.
    > >> >>
    > >> >> When I just run this:
    > >> >>
    > >> >> Get-EventLog security -newest 1 | Format-List
    > >> >>
    > >> >> no problem.
    > >> >>
    > >> >> It is as if Get-Date modifies something when it comes to Format-List.
    > >> >> It's
    > >> >> not only Get-Date that does it, commands like Get-Process and Get-Host
    > >> >> do
    > >> >> the same thing.
    > >> >>
    > >> >> How do I work around this problem?
    > >> >>
    > >> >> Per...
    > >> >>
    > >> >>
    > >> >>
    > >> >>
    > >>
    >
    >
    >

      My System SpecsSystem Spec

  9. #9


    Per Moeller-Olsen Guest

    Re: Format-List Issue

    Kewl

    "RichS" <RichS@xxxxxx> wrote in message
    news:40136F0E-A33E-41F8-96C6-5B1EE6F10DB5@xxxxxx

    > If you don't need the output in a file this will work
    >
    > Get-Date | Out-Default
    >
    > Get-EventLog security -newest 1 | Format-list
    >
    > --
    > Richard Siddaway
    > Please note that all scripts are supplied "as is" and with no warranty
    > Blog: http://richardsiddaway.spaces.live.com/
    > PowerShell User Group: http://www.get-psuguk.org.uk
    >
    >
    > "Per Moeller-Olsen" wrote:
    >

    >> Thanks everyone.
    >>
    >> This modified ps1 file also works:
    >>
    >> get-date > c:\scripts\test100.log
    >>
    >> get-EventLog security -newest 1 | Format-List | Out-File
    >> c:\scripts\test100.log -append
    >>
    >> $a = get-content c:\scripts\test100.log
    >>
    >> write-output $a
    >>
    >> Per...
    >>
    >> "RichS" <RichS@xxxxxx> wrote in message
    >> news:05FCE94C-417D-48C0-B83F-BA6EAFB7B418@xxxxxx

    >> >I put the lines in a script and recreated the result
    >> >
    >> > If I comment out the Get-date OR move the get-date after the
    >> > get-eventlog
    >> > line everything is fine
    >> >
    >> > using [System.DateTime]::Now instead of get-date generates the same
    >> > result
    >> >
    >> > However I did get this to work
    >> >
    >> > Get-Date -format g
    >> >
    >> > Get-EventLog security -newest 1 | Format-list
    >> >
    >> > You could try experimenting with other values for the format
    >> >
    >> > --
    >> > Richard Siddaway
    >> > Please note that all scripts are supplied "as is" and with no warranty
    >> > Blog: http://richardsiddaway.spaces.live.com/
    >> > PowerShell User Group: http://www.get-psuguk.org.uk
    >> >
    >> >
    >> > "Brandon [MVP]" wrote:
    >> >
    >> >> To repro do this
    >> >> get-date;Get-Eventlog security -newest1 | format-list
    >> >>
    >> >> "RichS" <RichS@xxxxxx> wrote in message
    >> >> news:5F432C72-B875-449F-8ABD-987BB94CFD67@xxxxxx
    >> >> >I cannot reproduce this error. What version of PowerShell and what
    >> >> >operating
    >> >> > system are you using?
    >> >> > --
    >> >> > Richard Siddaway
    >> >> > Please note that all scripts are supplied "as is" and with no
    >> >> > warranty
    >> >> > Blog: http://richardsiddaway.spaces.live.com/
    >> >> > PowerShell User Group: http://www.get-psuguk.org.uk
    >> >> >
    >> >> >
    >> >> > "Per Moeller-Olsen" wrote:
    >> >> >
    >> >> >> When I run this in PowerShell:
    >> >> >>
    >> >> >> Get-Date
    >> >> >>
    >> >> >> Get-EventLog security -newest 1 | Format-List
    >> >> >>
    >> >> >> I get this error:
    >> >> >>
    >> >> >> out-lineoutput : Object of type
    >> >> >> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is
    >> >> >> not
    >> >> >> legal
    >> >> >> or not in the correct sequence.
    >> >> >> This is likely caused by a user-specified "format-list" command
    >> >> >> which
    >> >> >> is
    >> >> >> conflicting with the default formatting.
    >> >> >>
    >> >> >> When I just run this:
    >> >> >>
    >> >> >> Get-EventLog security -newest 1 | Format-List
    >> >> >>
    >> >> >> no problem.
    >> >> >>
    >> >> >> It is as if Get-Date modifies something when it comes to
    >> >> >> Format-List.
    >> >> >> It's
    >> >> >> not only Get-Date that does it, commands like Get-Process and
    >> >> >> Get-Host
    >> >> >> do
    >> >> >> the same thing.
    >> >> >>
    >> >> >> How do I work around this problem?
    >> >> >>
    >> >> >> Per...
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >>
    >> >>
    >>
    >>
    >>


      My System SpecsSystem Spec

Format-List Issue problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Message list format Ildhund Live Mail 2 12 Jan 2009
-f format Format-Table Format-List against Select Personne PowerShell 5 25 Nov 2008
Format List on PromptForChoice zfan PowerShell 4 29 Feb 2008
Format-List Problem? Ward PowerShell 7 20 Nov 2007
How to get a list of PropertyName from the format-list cmdlet? Dung K Hoang PowerShell 4 07 Oct 2006