In PowerShell you group objects by properties with Group-Object
. What you want is not grouping in that sense, but defining a new custom property.
You create custom properties a hashtable with the Name
and Expression
keys.
Something like this will probably do the trick.
$Expression = {
if ($_.Application) {
$_.Application
}
else {
$_.Shortcut
}
}
$object |
Select-Object -Property @{ Name = 'Application'; Expression = $Expression }, Version, Architecture |
Sort-Object -Property @{expression="Architecture";Descending=$true},Application |
Out-GridView
The expression checks whether the Application
property is filled. If so, it will use the existing application name, otherwise it will take the Shortcut
property as application name.