1

When I use the select-object cmdlet, it only grabs the first property from the list of properties given to it. For instance

Get-ChildItem C:\tmp | Select-Object Name, CreationTime, Length

Returns to me only the Name and not the CreationTime or Length. If I put CreationTime first, I get only the CreationTime returned and not the other properties. It looks like the select statement is only processing the first argument and ignoring the rest. I have even tried using the -property parameter but that didn't help either

This looks like a very basic question, but where am I going wrong on this one?

I have confirmed I have PS 3.0. Here's a verbatim copy/paste of my command lines, as you can see only the Name is returned and not the length

PS C:\tmp> $psversiontable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.18046
BuildVersion                   6.2.9200.16434
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2


PS C:\tmp> Get-ChildItem | select Name,Length

Name
----
dls
gallery_uploads.txt
k.ps1
myscript.ps1
uploads.txt

Any ideas why this might be happening? I have tried this on 2 separate machines, a Windows 8 and a Windows Server 2008 R2, same result on both!

6
  • I cannot reproduce this behavior in v2 or v3. At first I thought it might be the spaces, but even with spaces I get all 3 properties returned. Commented Jun 19, 2013 at 16:28
  • Yes, it is very bizzare. I have this happening on 2 machines though, one a Windows 8 (above output is from that), the other is a Windows Server 2008 R2, both show the same behaviour Commented Jun 19, 2013 at 16:44
  • 1
    I can't repro this either. Start a new PowerShell session with -NoProfile and see if you still see the problem. Could be a module that is updating the formatting info for File/DirectoryInfo objects. Commented Jun 19, 2013 at 16:49
  • 3
    Is it possible that the second column is right aligned and appears at the right hand side of the console? It happens sometimes especially if you have a buffer wider than the console width. Does the console has horizontal scroll bars? Commented Jun 20, 2013 at 8:10
  • 1
    Ha!! that was it, the text was appearing wayyy on the right side of the screen, amazing! Thanks a lot Shay, mystery solved Commented Jun 20, 2013 at 10:04

1 Answer 1

3

In the interest of having an official answer to this post, the comment from Shay Levy was spot on, my screen buffer size was quite big, which meant the other columns were being displayed by I had to scroll the screen to the right to see it.

Thanks Shay

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.