PowerShell, Windows

Clone Existing GitHub PowerShell Scripts to Visual Studio 2015

If you are like me and not a developer but starting out with PowerShell, seeing everyone mention Visual Studio 2015 with the awesome PowerShell Tools extension and wondering how you could get your existing scripts into a more structured way of development and debugging while still utilising GitHub then you are not alone. Thanks to Trevor Sullivan video answer to my tweet and as a compliment to it, I take you step-by-step through the process:

Prerequisites

Extensions mentioned above can be downloaded via the Tools > Extensions and Updates portal in Visual Studio 2015 if you search for them there.

Step 1. Login to GitHub

  1. Select Team Explorer from the bottom tab on the right-hand side followed by Connect under the GitHub providers.
img_55cf2ff39953f img_55cf300e65a34

 

Step 2. Repository Cloning

  1. Now that you are connected select Clone under GitHub
  2. Select which repository you want to clone and then click Clone
  3. Once the repository has been successfully cloned you will see it appear under the Local Git Repositories

Step 3. Creating a project in Visual Studio

  1. Right-click on the newly cloned repository and select Open
  2. In the new view select New under Solutions
  3. In the New Project window:
    1. Select PowerShell under Templates
    2. Select your type of project – either a PowerShell Module or Script
    3. Name it the exactly the same as your GitHub repository
    4. Remove anything else after the local repository path as this will create a directory within the parent directory
    5. Deselect Add to source control

Step 4. Linking your random script files to the Visual Studio project

In Solution Explorer

  1. Right-click on the project
  2. Go to Add
  3. Click Existing Items

Select your random script/files and click Add

You will now see them under your project

Step 5. Committing and synchronizing changes to GitHub

  1. Go to Team Explorer
  2. Select Changes

Add any untracked files to the commit:

  1. Write your commit log
  2. Select Commit and Sync

You will be asked to save any changes – select Yes

If successful you will see the following message and finally in GitHub
img_55cf3ceaa6edb img_55cf3d125b8a2

Note

If for some reason you do not see your files under Included Changes

You have to go Solution Explorer and open them, inserting a space or something and then saving them. You will see that the file icon changes from a small lock to a red tick – once done your files will appear under Included Changes

twitterredditpinterestlinkedinmail

Leave a Comment

Your email address will not be published. Required fields are marked *