What is the default order of result set from Get-ChildItem command in powershell? Is there a order at all or is it just random and would give the results in a different order every time.
There is no guaranteed default sort order. The documentation doesn't state one.
The implementation in FileSystemProvider
ends up calling DirectoryInfo.GetFiles
. The documentation for that states
The order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.
The underlying API calls are FindFirstFile
and FindNextFile
. Raymond Chen explains here that in practice the file system driver may observe some ordering rules but this should not be relied upon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With