In this article we will observe how to invoke a video file from SQL Server using PowerShell.
While answering to a question in DotnetFunda Forum, we came upon this question which we found to be interesting not because of the fact that we have never done it before but because of the fact we felt it will be a new adventure for us to answer this (if at all it is possible!!!). And after we answered,we felt there is a need for an article in order to write down the process for this solution/approach.Here we are presenting our approach for the same.
Suppose we have a video file in our hard disk. How can we run/execute that one from SQL Server Management Studio(SSMS)?
The approach we took is that we are invoking the video file from the PowerShell Script and invoking that PowerShell scriptlet from SQL Server Management Studio(SSMS).Below is a step by step guidance for the same.
Consider that we have a video file located at "D:\songs\1.mp4".Open any text editor and let us write the following command.
Start-Process -FilePath "D:\songs\1.mp4"
The purpose of the Start-Process command is to start process(s) on the local computer. The -FilePath Parameter indicates the location of the program that runs in the process.
A detailed explanation about Start-Process is available here.
Save the file say in our case we saved at "D:\" with the file name as "RunVideo.ps1".
Open SSMS with "Administrative Privilege"
Open Object Explorer by clicking on View -> Object Explorer from ToolBar or by Pressing F8
Right click on the SSMS instance and from the PopUP window, choose Start PowerShell
Click on Start PowerShell and we will receive the below window
Type the following command in the "SQL SERVER POWERSHELL" command prompt
Hit ENTER button and enjoy the hard work
In this article we have seen how to invoke a video file from SQL Server using PowerShell. We hope that the article will be useful as it shows the interaction of PowerShell with SSMS. Thanks for reading.