This issue isn't reproducible in PowerShell 7 latest, but in Windows PowerShell 5.1 Group-Object
with a string property (-Property weight
) doesn't know how to handle incoming hash tables (@{ ... }
) from pipeline but you can help it using a calculated expression instead:
@(
@{ name = 'a' ; weight = 7 }
@{ name = 'b' ; weight = 1 }
@{ name = 'c' ; weight = 3 }
@{ name = 'd' ; weight = 7 }
) | Group-Object -Property { $_.weight } -NoElement