I have a script file in my local machine. I have to open SSMS and open the query in SSMS and to execute the query.
For opening the SSMS and query, i have used the following PowerShell script to do it.
ssms.exe 'E:\PowerShell_PROD\Screenshot\ServerDetails.sql' -E -S localhost
How can i run this query using PowerShell and how can i close this query window?
The reason I'm doing this is I have to take the evidence of the SQL Server properties and other information. For that I have a PowerShell script to capture the screenshot.
I'm preparing the PowerShell script that runs every query in SSMS and captures the outcome of that and save into specified path. Now am able to open the query in SSMS and capture the screenshot, but I'm unable to run the query.