hi is it possible to pass a list of properties to a Select-Object cmdlet as a variable?
Do you mean so that you don’t have to type them out every time? I’m just starting out on this forum so my answer might not be perfect, but storing the property names in an array then using them in select-object sounds like what you mean? (Let’s see how I get on with formatting the code!)
$Properties = @("Handles","ProcessName","Id") Get-Process | Select-Object $Properties
Yes, that is possible. You just need to create an array. The array can contain strings representing the names of the properties, expressions (hashtables) to create calculated properties, or both depending on your use case.
$propertyList = 'Id', 'Name', 'Threads' Get-Process | Select-Object -Property $propertyList
thanks, just what i needed