PowerShell cmdlets return objects with rich information, and to see all the information, you can pipe the result to Format-List *:
You can easily append more properties if the information returned is not sufficient. For example, open Notepad and enter this to add a property called "Age" that returns the age in days for a file:
<Type>
<Name>System.IO.FileInfo</Name>
<Members>
<ScriptProperty>
<Name>Age</Name>
<GetScriptBlock>
(new-timespan $this.LastWriteTime).Days
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
Save it as fileage.ps1xml. Next, update PowerShell using this command:
Once done, you can show the Age column and even use it to retrieve old or brand new files whenever you list files:
The next line selects recursively all log files in your Windows folder, which have been modified within the last 30 days:
Where-Object { $_.Age -lt 30 } |
Format-Table FullName, Age