Powershell Format-Table HELL!

#Powershell

This really is killing me, I am getting it more an more.

Basically if I create an array I want to send the output to the screen using Format-Table.

In the shell it works fine, but when I use a .ps1 I am constantly getting

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], InvalidOperationException
+ FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand

What the hell is going on?! Why is the shell different to a .ps1

I don’t want a list, all I want is a table! .. Select-Object can’t make up its mind if it want to use a table or list and I done see anyway around it .. Event exporting to CSV and reimporting fails!

Comments

  1. Hi,

    Have a look at this Connect item for explanation and workaround:
    http://connect.microsoft.com/PowerShell/feedback/details/152205/bug-with-default-formatter

    -Jan-

  2. I have found that I need to put the format after the script. So, I would run scriptname.ps1 | ft

Leave a Reply

%d bloggers like this: