0

I'm getting the following error and I don't understand why or what it's asking for.

The object I'm trying to display in a table is:

function newURLObject()
{
#  param ([String]$Value, [Int]$Count = "1", [String]$IP )
   param ([String]$Value, [Int]$Count = "1" )


  $obj = new-object PSObject
  $obj | add-member -type NoteProperty -Name Value -Value $Value.substring(1)
  $obj | add-member -type NoteProperty -Name Count -Value $Count
 # $obj | add-member -type NoteProperty -Name IP -Value $IP

  return $obj
}

The basic flow is the following.

#< Declare Objects>
#< Code to create an array of those objects >

$z = @{Expression={$_.Count};Label="Count";width=5}, @{Expression={$_.Value};Label="URL";count=35} 

$y = $listOfRequestedURLs  | sort count -descending | select -first 30 | ft $z 


Format-Table : Illegal key count
At C:\Temp\parse IIS logs.ps1:231 char:8
+ $y | ft <<<<  $z
    + CategoryInfo          : InvalidArgument: (:) [Format-Table], NotSupportedException
    + FullyQualifiedErrorId : DictionaryKeyIllegal,Microsoft.PowerShell.Commands.FormatTableCommand

I know the values are in the array; but it won't display properly. If I display it without the format-table the value field just shows up as empty.

1 Answer 1

6

You have an illegal format key name, remove it (or rename it to width?):

@{Expression={$_.Value};Label="URL";count=35}

Sign up to request clarification or add additional context in comments.

3 Comments

Err.. sorry for being dense but I don't understand the difference with what you've bolded.
Valid key names are: Expression,FormatString,Label/Name,Width and Alignment. Clearly Count is not one of them.
Depth is also a valid key name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.