Reputation: 3634
How to remove path when I type ls
in PowerShell. I would like formatting of other items to stay the same, (Mode
, LastWriteTime
, Length
, Name
). Just to remove line Directory C:\
. I have been playing around and I'm able to remove it, but then can't get formatting of other items right.
Upvotes: 0
Views: 424
Reputation: 68331
The formatting you see on the screen is determined by the Format.ps1xml file.
The format changes when you use Select-Object
and select specific properties because you've change the object type (if you do a get-type()
you'll see it's now a PSSelectedObject
or PSCustomObject
), and that formatting is no longer applied.
I think the easiest way to get what you're after may be to override the Format.ps1xml file with a new entry that doesn't display the directory name.
Upvotes: 1