Many console-based tools like driverquery, whoami, or tasklist provide useful information but the column names are localized and may differ, depending on the language your system uses.
One way of accessing columns regardless of localization: access columns by position rather than name. To do this, you can use PSObject to find out the localized names, and then pick the names based on a numeric index.
This line will get you a list of computer system properties. Note how column names are localized:
PS> systeminfo /FO CSV | ConvertFrom-Csv | Out-GridView
To pick just the columns “OS Name”, “Product ID”, “Original Installation Date” and “System Model” in a language-neutral way, you’d want to pick columns 1,8,9 and 12. Here is how:
PS> $data = @(systeminfo /FO CSV | ConvertFrom-Csv) PS> $columns = $data[0].PSObject.Properties | Where-Object { $_.MemberType -eq 'NoteProperty' } | Select-Object -ExpandProperty Name PS> $data | Select-Object -Property $columns[1,8,9,12]
So on a German system, you’d get exactly the columns you wanted regardless of how they have been localized.
Just exchange the console tool call to get the information you are after. With just a slight change, you could for example use tasklist.exe to return process name, PID, process owner and process status (which are the columns 0, 1, 6 and 5):
PS> $data = @(tasklist /V /FO CSV | ConvertFrom-Csv) PS> $columns = $data[0].PSObject.Properties | Where-Object { $_.MemberType -eq 'NoteProperty' } | Select-Object -ExpandProperty Name PS> $data | Select-Object -Property $columns[0,1,6,5]
Or, you can display the process sessions by picking different columns:
PS> $data | Select-Object -Property $columns[0,3,2,6]
You can of course look at all available columns anytime to pick the ones you want:
PS> $data | Select-Object -Property * -First 1