Flatten array in PowerShell

Piping is the correct way to flatten nested structures, so I’m not sure what would be more “elegant”. Yes, the syntax is a bit line-noisy looking, but frankly quite serviceable.

2020 Edit

The recommended syntax these days is to expand % to ForEach-Object. A bit more verbose but definitely more readable:

@($a | ForEach-Object {$_}).count

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)