Format-
cmdlets. Until I read Dons book I didnt realize the Format-
cmdlets worked with expressions in the same way that Select-Object
does. As I worked through the chapter I realized this would pretty helpful. For instance, in a situation where I would use Select
with an expression it does not necessarily allow formatting. So, instead ofusing
Select
I opted for Format-Table
so I could use the -Auto
to get things to fit more neatly. In this example, I used Format-Table -Auto
with an expression to get the date (MM/dd/yyyy format) and the file name only:dir | ft @{e={$_.lastwritetime.ToString(MM/dd/yyyy)};l=Date},name -auto | clip
| clip
on the end just passes the output to the clipboard so I can paste it later.