RSS

Tag Archives: Visual Studio Code

PowerShell – Getting started with Visual Studio Code and GitHub

In the past years I’ve been creating scripts and storing them on my personal OneDrive that is connected to multiple desktops and laptops I use. Additionally, my Synology NAS syncs with OneDrive and backups the files to ChrashPlan.

Even though this works, it has some disadvantages:

  1. OneDrive provides basic version history, but it is limited to just the file at a point in time. When modifying scripts I would need to create a new version and file to ensure I would be able to go back to a previously working version. In the past, especially when I just got started with PowerShell I screwed up code that was working before and that cost me a lot of time to get working again.
  2. The file is only available to me and the people I explicitly share it with. Therefore a lot of general use scripts I’ve created will not be findable and usable by others and I cannot benefit from suggestions/improvements from others which would also help me create better code.

These are the things I plan to solve by using GitHub with Visual Studio Code.

These are the steps I did to get started:

  1. First thing I did, was install Visual Studio Code 1.23.1 (even though I love PowerShell ISE especially with ISE Steroids and will probably still use in parallel). Then I configured it as a replacement for the PowerShell ISE as described by Mike F Robbins in his blog post “How to install Visual Studio Code and configure it as a replacement for the PowerShell ISE”.
  2. Then I created an account on GitHub and followed the Hello World guide to get better acquainted with GitHub and its concepts. At the bottom of this page additional training was offered as a tip: GuidesYouTube Channel and On-Demand Training , but I decided to check this out later.
  3. I then configured Git for Windows and Visual Studio Code by following the blog post Use Git with Visual Studio Code by Brandon Lee.

Everything worked correctly from home and I started following examples shown in “Git Version Control in VS Code”.

When I got at work it did not work anymore however and after some time I got an error in Visual Studio Code stating:
Git: fatal: unable to access ‘https://github.com/bjornhouben/PowerShell.git/’: Failed to connect to github.com port 443: Timed out

Since we use a proxy at work, I quickly figured this would be the most probable cause. So first I determined the proxy server by checking our WPAD file using http://wpad.domain.local/wpad.dat. Then I went on to determine how to configure Visual Studio Code to use the proxy server and came across the articles “Network Connections in Visual Studio Code” and “User and Workspace Settings” , but both did not solve my problem even after restarting Visual Studio Code. Then it hit me that Git For Windows was being used to connect to GitHub. I then quickly found out that I had to run GIT Cmd and configure the proxy using: git config –global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 and after restarting Visual Studio Code it worked correctly again. When I’m working from home without VPN I simply unset the proxy configuration using GIT Cmd using: git config –global –unset http.proxy and restart Visual Studio Code.

 
3 Comments

Posted by on May 28, 2018 in Automation, ICT, Microsoft, Powershell

 

Tags: , , , , , , , ,