Link to home
Start Free TrialLog in
Avatar of MarkhamLA1979
MarkhamLA1979Flag for United States of America

asked on

Cannot format Output with line continuation

I have the following code:

clear

$computers = get-content servers.txt

Get-Date

foreach($i in $computers)
{ 
	write-host $i
	gwmi -query "SELECT Caption,VolumeName,Size,Freespace FROM win32_logicaldisk" -computer $i | 
        Select-Object `
            Caption,`
            VolumeName,`
            @{Name="Size(GB)"; Expression={"{0:N2}" -f ($_.Size/1GB)}},`
            @{Name="Freespace(GB)"; Expression={"{0:N2}" -f ($_.Freespace/1GB)}},`
            @{Name="Percent Free"; Expression={"{0:N2}" -f ($_.Freespace/$_.Size*100)}} |
        Format-Table
	
	Get-Eventlog System -EntryType Error -computerName $i -Newest 25 | Format-List


}

Open in new window


I get this error when I run it:


Tuesday, 06 September, 2011 08:28:03
SERVER NAME
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 th
e default formatting.
    + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
    + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
[PS] F:\PowerShellScripts\SrvScripts>

It worked fine for me until I put in the ` marks for line continuation. I am sure this is simple, but I appreciate the help.
ASKER CERTIFIED SOLUTION
Avatar of gazm81
gazm81

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial