Select-Object can add new properties to objects and fill them with calculated content. All you need for this is a hash table with two pieces of information: "Name" (which is the new property name) and "expression" (which is the code used to calculate the property content).
$age = @{Name='Age';
expression={ (New-TimeSpan $_.LastWriteTime).Days }}
dir $env:windir |
Select-Object name, $age |
Export-CSV c:\test.csv
ReTweet this Tip!
Posted
Dec 11 2009, 08:00 AM
by
ps1