I know the need to filter but this has always stumped me with a query like this where the properties does not exist in the default view. ie:
Get-Adcomputer -filter {$_.operatingsystem -like "*2012 R2*"} -properties operatingsystem
This gives an error and I can understand why because properties is outside the filter scriptblock.
If I try :
Get-Adcomputer -filter {$_.operatingsystem -like "*2012 R2*" -properties operatingsystem }
So now i can only resort to putting that in where-object.
Can I do this better and then comply with best practices?