Only want a list of file system entries and not a list of file system objects ?

This post follow the spirit of the previous one…

“Sometimes do not use the Powershell Cmdlets, .NET in place”

Get-ChildItem, is a very fast Cmdlet but if you only want an array of full names instead of an array of objects, there is a .NET function you should try : System.IO.Directory.GetFileSystemEntries

Lets try this piece of code that will retrieve 11207 file system entries :

And here the result I got…

Get-ChildItem Elapsed Time: 1491
Get File System Entries Elapsed Time: 199

Of course GetFileSystemEntries only returns an array of string but it is about 7 time faster !!!