I have an automated Powershell process that ends with an Invoke-Item command to open multiple SQL files (currently 4 SQL files) for the testers, so they can run their scripts. Keep in mind, I am not executing their scripts, I am just opening them after my processes end. The testers can open the scripts themselves of course, but I am hoping to be able to lay everything out for them.
The issue is, the SQL scripts always open in multiple SSMS instances, usually 3 files on the first and 1 on the second, but occasionally 2 and 2. (When I expanded the number of SQL files to 10, I get four instances with 3, 3, 2 & 2 files in each.)
I have servers at different SQL versions, so the path to the executable may be different between systems. So calling the EXE directly with the filenames appended is not an option, unless I add logic to find the correct path to the EXE's beforehand.
Note: These are different SQL versions (2008R2 to 2017) and the SSMS version would be the version that came with the installation rather than the new standalone SSMS
How do I get all of the SQL files to open under a single SSMS instance from Powershell?
$sql = (Get-ChildItem -Path C:\Temp\Export | Where-Object {$_.Name -like "*.sql"}).FullName
II $sql