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.
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