Can I not use a WHERE in the pipe after an @{name alias?
I have to use custom column headers in my output so I am using the @{name syntax. Later in the pipe, the sort works using the alias I've given it but the WHERE clause does not. I've tried going back to the original $_. variable name but they does not seem to work either. When I take the WHERE clause out, I get my output with the aliased headings.
EXAMPLE with no @{Name alias and the WHERE works
PS C:\> Get-WmiObject Win32_operatingsystem | select version,BuildNUmber | where { $_.buildnumber -eq 3790} | sort version
version BuildNUmber
------- -----------
5.2.3790 3790
EXAMPLE with alias and WHERE does not work
Get-WmiObject Win32_operatingsystem | select @{Name="Ver";Expression={$_.version}}, @{Name="Build";Expression={$_.BuildNUmber}} | where { "build" -eq 3790} | sort "ver"
EXAMPLE with alias and NO WHERE, gets output. SORT uses alias and works as well.
PS C:\> Get-WmiObject Win32_operatingsystem | select @{Name="Ver";Expression={$_.version}}, @{Name="Build";Expression={$_.BuildNUmber}} | sort "ver"
Ver Build
--- -----
5.2.3790 3790
So Ideally I'd like to be able to use the @{name with a WHERE clause..