Powershell:格式表:非法键计数
我收到以下错误,我不明白为什么或它要求什么。
我试图在表格中显示的对象是:
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
我知道这些值在数组中;但它不会正确显示。如果我在没有格式表的情况下显示它,则值字段只会显示为空。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的格式键名称非法,请将其删除(或将其重命名为 width?):
@{Expression={$_.Value};Label="URL";count=35}
You have an illegal format key name, remove it (or rename it to width?):
@{Expression={$_.Value};Label="URL";count=35}