How I moved from the Powershell ISE over to Visual Studio for my Skype4B scripts Part 1

By | October 3, 2016

Wait another part 1? But he hasn’t finished the Audiocodes CloudBond Review
Yeah I apologise for that. I’ve been pulled off to a customer site and I’ve had to rebuild my lab. So that’s coming soon.

Anyway, I was asked on twitter to document the process of me moving over to Visual Studio and Git on Visual studio Team Services for all my local PowerShell scripting work. If you’re interested in improving your Powershell scripting process or maybe implementing GUI Wrappers around existing cmdlets. Read-on, there is no Skype for Business content in this article so if you’re looking for that, check out my scripts page.

Anyway I’m a coder from way back, writing things in basic on the C64 and QBASIC in dos when I was a kid, Moving up to VB5 and 6 when I was a teenager, then real life kicked in and I started in the support trenches getting users to turn things off and on again.

These days now I focus on just Skype for Business, I try to optimise my process as much as I can. That has meant a return to coding. Initially dodgy hacks in Powershell to “Get the job done” but now moving into more complicated GUI’s and the like.

Up until now, I’ve been doing all my PowerShell work in the Powershell ISE, which is fantastic for smaller scripts but once we start adding XAML gui code and heaps of functions. It can become a small nightmare to manage. Not to mention version control suffers from “Latest – newest- no this one.ps1” issues.

First off, if your just looking at how I do GUI’s for my PowerShell tools, go check Stephen Owen’s blog over here https://foxdeploy.com/resources/learning-gui-toolmaking-series/ as everything I know I learnt from there and is one of the main reasons I switched to using Visual Studio.

As I was writing GUI’s I’d write the WPF code in Visual Studio, then switch over to the ISE. Paste the XAML and run the code. A bit of a pain if I was making small UI changes as well as I’d have the GUI saved in one app and the Powershell in another. Let alone version management was a mess. It was literally me copying and pasting the folders that contained the content and amending “.old” or “Before awesome mega feature”

versioncontrol-allthethings

Not exactly awesome. But workable if your just doing simple things.

One of the biggest pushes for me however was the fact I needed to separate versions of scripts that customers have paid for me to write based off my freeware scripts from stuff I can distribute freely and if I make an improvement or bug fix to the free one. There should be an easy way to integrate those changes to the paid ones. (one of the issues being a consultant I guess)

Another nice feature is the ease of having development forks. So I can work on feature XYZ, whist another team member works on feature ABC. We can save and test our work separately from the main code, then upload to the server for integration.

This is where Git comes in. Microsoft has done a fantastic job of helping coders out over the recent years and is getting more and more open as the time goes with free tools and now even services available to anyone with a Microsoft Account

Anyway, enough rambling. On to how to do it.

Like I said, I learned a lot of this information online and need to give credit where its due. So let’s start with that.

Stephen OwenPowerShell Gui making series
Don Jones – Learn PowerShell in a Month of Lunches (Book) (Youtube)

Handy video that shows what Visual Studio can do With Powershell
Tools for Powershell demonstration https://www.youtube.com/watch?v=eRILgGQb_hQ
Visual Studio Git Tutorial. A fantastic tutorial for Git. Not written by Unix nerds
https://www.visualstudio.com/en-us/docs/git/tutorial/gitworkflow
Anyway, let’s get on with it.
First things first, head over here and download the latest version of Visual Studio Community 2015
https://www.microsoft.com/en-us/download/details.aspx?id=48146
Run the installer and select “Custom”

vs1
In the features list, Expand “Windows and Web Development” and select “Powershell Tools for Visual Studio [3rd Party]”

vs2
Expand “Common Tools” and Select “Git for Windows” you can also use install the Github plugin if you have a GitHub Repo

vs3

Click Next, review the licence terms and click “Install” then follow the bouncing ball

vs4

This will take a while as it downloads all the required packages
Once Visual studio has finished installing all its bits smack the big “Launch” button

Once Visual Studio launches it will offer to connect you to Visual Studio Team Services, just click “Sign in” and put in your Microsoft Account details if requested.

vs5

vs6

After signing in, create your Visual Studio Team Services profile, this allows you to host your own code repo’s (IE Git) and even project management for upto 5 users for free.

There’s a lot of features we don’t need, but it’s nice to know there is room to grow!

vs7
The Wizard will take you through setting up your first project, make sure you select the “Git” version control system. This allows you to work on your stuff offline as you have your own local “Repo” (copy of the project) separate from the server

The Process template is less relevant unless your actually managing a team of developers or are using the Visual Studio built in tools for managing features/bugs/workload. I personally use my OneNote.
A quick note on Git.

Git keeps track of your changes via “Commits”. Each time you “Commit” something you are saving changes to the local repo along with a brief description of what you changed (This is different from saving files, you have to save before you can commit) Once you’re ready to share your changes you “Push” them to the hosted Git repo. At the same time your client will “Pull” any changes pushed by anyone else in that fork (variant) of the code

At that time, if there are any conflicting changes in the same files (typically PowerShell scripts are only one file anyway) Visual Studio gives you the opportunity to review and merge those changes. This is really helpful when you want to work on multiple variants of a script! More on that later.

If this seems a little confusing right now. Don’t worry. I’ll post some examples that explain it all in the next article. Otherwise the Visual Studio Team have some great doco here https://www.visualstudio.com/en-us/docs/git/tutorial/gitworkflow

vs8

The next few steps are up to personal preference, but I like the Dark Theme using the “General” development environment
You should now get dropped into Visual Studio

vs0

If you had issues signing in (as I did during the wizard) you can sign in using your Microsoft account in the top right corner of the ISE (in our case, Integrated Scripting Environment)

vs9

Otherwise its time to kick off your first project and we can do that in Part 2

2 thoughts on “How I moved from the Powershell ISE over to Visual Studio for my Skype4B scripts Part 1

  1. Pingback: How I moved from the Powershell ISE over to Visual Studio for my Skype4B scripts Part 3. A Pushme Pullyou – Skype4BAdmin.com

  2. Pingback: How I moved from the Powershell ISE over to Visual Studio for my Skype4B scripts Part 2. The Return of the VB ISE! – Skype4BAdmin.com

Leave a Reply