While we are using Visual Studio 2015 with GitHub for all SharePoint C# projects, we would like to manage the PowerShell or other scripts in the same way as Visual Studio projects. We could integrate the scripts with Visual Studio projects, GitHub, and be able to run and debug without leaving Visual Studio to improve developers’ productivity. Here are the procedure that will help you to set up.
1. First you need to install the Visual Studio 2015 with GitHub extension. See my previous blog for details.
2. Second you need to install PowerShell tool for visual studio 2015.
3. Third you can create the Powershell Project like the screenshot below. You can organize the folders, scripts, and documents same way as other SharePoint project as described here.
4. You can integrate the GitHub just like other C# code as described in previously blog.
5. Now you can add command or shortcut key when right click the PowerShell script or somewhere else like the screenshot below.
You can see there is default command named "Run with PowerShell ISE" available. You can invoke the command and run PowerShell. However, everytime the code changed, you need to invoke this external UI again. Here is easy way to set up ti run the PowerShell and debug directly from Visual Studio just like the screenshot above with "Run powershell script in output window".
The steps are described in Nick's blog.
6. Next, you need set the PowerShell execution policy using Set-ExecutionPolicy to avoid the exception. Please you need to run as admin and on the PowerShell version you are using like X86. You may also need to run the Visual Studio as admin.
7. You might need to update PowerShell config as described here to enable attaching PowerShell to some process for debugging.
Now you can enjoy developing, collaborating with GitHub, running, and debugging the PowerShell directly inside Visual Studio!