SQL Server 2017 RC1 dropping recently reminded me of a couple things I wanted to blog about finding in there. One that I thought was rather interesting is a new iTVF called
dm_os_enumerate_filesystem. It looks like a partial replacement for
xp_cmdshellin that, well, you can do the equivalent of running a
dircommand, with some filtering.
The addition of a search filter is particularly nice, since the
dircommand isn’t exactly robust in that area. If you’ve ever wanted to filter on a date, well… That’s probably when PowerShell got invented.
If I run a simple call to the new function like so…
Click through to see Erik use the new function.