dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Show-SqlServerFileSystem

This command will shows a treeview populated by directories enumerated by SQL Management Objects (SMO) EnumDirectories() and EnumAvailableMedia(). This, essentially, is a window to the one you’re presented by in SSMS. Once you select a path, a string of that path will be returned.

All files shown are only files that you have permission to see, as granted by SQL Server itself. We use this command internally in dbatools, but wanted to share it with you in the event you’d like to include it in your own scripts.

Examples

To show a GUI that logs into a server Windows Authentication. Returns a string of the path you selected.

Show-SqlServerFileSystem -SqlServer sqlserver2014a

Shows a GUI and uses SQL credentials to log into the SQL Server. Returns a string of the path you selected.

Show-SqlServerFileSystem -Source sqlserver2014a -SqlCredential $cred

wpf

Get-Help

From PowerShell, execute Get-Help Show-SqlServerFileSystem -Detailed for more information on this function.

Source Code

Want to see the source code? View Show-SqlServerFileSystem.ps1 on GitHub
 

Related commands