Powershell: Format-Table : Illegal key count
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 form开发者_如何学运维at-table the value field just shows up as empty.
You have an illegal format key name, remove it (or rename it to width?):
@{Expression={$_.Value};Label="URL";count=35}
精彩评论