Descending list in Powershell
How do I get the a name of a list of the content of a folder in descending order in PS?
- I just want to get a name of folders of a path.
I am using Get-ChildItem
, but I don't know how to go any further.
you can use the following command:
gci c:\YOUR_PATH | ? { $_.PSIsContainer } | sort CreationTime -Descending | select -Property Name | foreach { $_.Name }
gci is the short version of Get-ChildItem
$_.PSIsContainer will filter the folders available in the current context.
sort CreationTime -Descending will sort descending the content of the output.
Select -Property Name Will select the property "Name."
foreach { $_.Name } will process item per item.
For more help please use the Get-Help cmdlet.