0

我收到以下错误,我不明白它为什么或要求什么。

我试图在表格中显示的对象是:

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
}

基本流程如下。

#< 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

我知道这些值在数组中;但它不会正确显示。如果我在没有格式表的情况下显示它,则值字段将显示为空。

4

1 回答 1

6

您有一个非法的格式键名,将其删除(或将其重命名为宽度?):

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

于 2011-07-18T16:24:05.237 回答