Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone explain, why this ( powershell 2.0 )

$wmi=Get-WmiObject Win32_UserProfile
$wmi|select *;
$wmi|select SID;
$wmi|select LocalPath;

gives expected results ( selected everything, then selected SIDs, then LocalPaths), while these two gives

$wmi=Get-WmiObject Win32_UserProfile
$wmi|select LocalPath;
$wmi|select SID;
$wmi|select LocalPath;

LocalPaths, nothing, LocalPaths

Get-WmiObject Win32_UserProfile|select SID;
gwmi win32_UserProfile|select LocalPath;
gwmi Win32_UserAccount|select *;

SIDs, nothing, SIDs again Is there only one instance of select ?

share|improve this question
"...while these two" what? What are you asking? – August Feb 7 '13 at 20:07
repaired it, busy night yesterday – Denwerko Feb 8 '13 at 20:16
I do not see the same behavior. Copy/pasting into a v2 PowerShell session here produces no empty values. What do you get for $wmi.Count and ($wmi | select SID).Count? – jscott Feb 8 '13 at 20:59
outputs of all three commands and counts that you requested are here . – Denwerko Feb 8 '13 at 21:39
up vote 0 down vote accepted

You're running into a weird edge case of how the formatting of output in powershell works. Please see this description of the issue from Jeffrey Snover.

I can only reproduce this behavior when running the commands all on one line like so:

$wmi=Get-WmiObject Win32_UserProfile; $wmi | select localpath;$wmi|select SID; $wmi | select localpath

This must be (speculating here) because the entire line is submitted to Out-Default as a batch; if you run each command individually, you don't see this behavior.

But with one call to Out-Default, it first sees the Selected.System.Management.ManagementObject with one property, 'LocalPath', so it creates a table with one column, for 'LocalPath.' Once you get some Selected.System.ManagementObjects with a 'SID' property, they appear in the table as nulls, because their 'LocalPath' property (the only one Format-Table knows to display) is null.

This problem doesn't happen in the first example because the 'select *' causes Out-Default to choose Format-List as the formatter, which is much less lossy.

I hope this helps -- the blog post I linked explains it very well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.