Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How do I use the property of a property?

Reply
 
Old 07-28-2008   #1 (permalink)
John Vottero


 
 

How do I use the property of a property?

I can do:

dir | ft LastWriteTime

and I get a list of the last write time for each file in the current
directory. But, when I do:

dir | ft LastWriteTime.Hour

I get a blank line for each file in the directory.

Also, when I do:

dir | ft LastWriteTime.ThisIsInvalid

I get the same results as when I use the .Hour property even though I'm
using an invalid property.

I think I'm missing something very basic, how do I use the property of a
property?

Thanks,

John Vottero


My System SpecsSystem Spec
Old 07-28-2008   #2 (permalink)
Kiron


 
 

Re: How do I use the property of a property?

You can use a calculated property:

dir | ft @{label='Hour'; expression = {$_.LastWriteTime.Hour}} -a

dir | ft LastWriteTime, @{label='Hour'; expression = {$_.LastWriteTime.Hour}} -a

--
Kiron
My System SpecsSystem Spec
Old 07-28-2008   #3 (permalink)
Shay Levy [MVP]


 
 

Re: How do I use the property of a property?

Hello John,


Try this:

PS > dir | ft {$_.LastWriteTime.Hour} -auto


To get a nice readable coulmn name use a the full calculted property syntax,
see the help for more information:


PS > dir | ft @{label = "Hour";expression={$_.LastWriteTime.Hour}} -auto


---
Shay Levy
Windows PowerShell
http://blogs.microsoft.co.il/blogs/ScriptFanatic

JV> I can do:
JV>
JV> dir | ft LastWriteTime
JV>
JV> and I get a list of the last write time for each file in the current
JV> directory. But, when I do:
JV>
JV> dir | ft LastWriteTime.Hour
JV>
JV> I get a blank line for each file in the directory.
JV>
JV> Also, when I do:
JV>
JV> dir | ft LastWriteTime.ThisIsInvalid
JV>
JV> I get the same results as when I use the .Hour property even though
JV> I'm using an invalid property.
JV>
JV> I think I'm missing something very basic, how do I use the property
JV> of a property?
JV>
JV> Thanks,
JV>
JV> John Vottero
JV>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Set Focus To Specific Property In Property Grid .NET General
Value under the CPU property? PowerShell
How to set file property # to a value > 99 Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46