Format-Table Error, please help

Hello all

I am a newbie learning my way through the powershell world, I am getting this error, can’t seem to figure out why.

PS C:\WINDOWS\system32> Get-EventLog -List | Format-Table @{1=‘Logname’; e={$.logdisplayname}}
Format-Table : The Int32 key type is not valid. The key must be a string.
At line:1 char:22
+ … t-EventLog -List | Format-Table @{1=‘Logname’; e={$.logdisplayname}}

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:slight_smile: [Format-Table], NotSupportedExcepti

  • FullyQualifiedErrorId : DictionaryKeyNonString,Microsoft.PowerShell.Commands.For



You have a typo in your code. It should be

Get-EventLog -List | Format-Table @{l=‘Logname’; e={$_.logdisplayname}}

BTW: Next time format your code as code please. Thanks

Thank you so much Olaf, the classic mistake it was, reading l as 1…

That happens when you don’t know the basics of Powershell. You should start to learn that first. :wink: