try this:
Get-ChildItem $filepath | ? { $_.PsIsContainer} | Sort LastWriteTime -Descending | Select -expa Name -First 1
I've anticipaded the where-object
, aka '?'
, for better performance.
With select-object
the {}
are needed only for calculated properties and to avoid the coloumn name use the -expand
parameter.