My Homework – GitHub and PowerShell

Beware….it turns out when you go to a local VMUG, you might be assigned homework.  This turned out to be the case for me a couple of weeks ago while attending the Louisville VMUG.  During his ‘Automating the Next Generation DC’ session, Josh Atwell assigned all attendees some homework: Establish a GitHub login, build a repository, download the GitHub desktop and commit some work.  Turns out I have been well intentioned for quite some time to fuss around with GitHub, see how it works, and it possibly share some of my PowerShell scripts in the process.  Homework assignment accepted.

1. Establish a GitHub Login

Browse on over to GitHub and create a login.  The Bootcamp will walk you through the steps, which simply includes creating a login & password

GitHubBootCamp

2. Build a Repository

Once having a login, it is time to create the first repository.  I will call my PowerShell, as this will become my library for my PowerShell scripts, which will be version controlled using GitHub.

New Repository

PowerShell Repository

3. Download GitHub Desktop

Now that I have a repository built, let’s download the GitHub Desktop client.  There is one for Windows and Mac.  I will be using the Windows version as that is where I have the PowerShell ISE installed and the Windows world obviously is where I utilize my PowerShell scripts.  Upon installing and launching for the first time, the client prompts for your GitHub login – this will then tie you into the repository created in Step 2.

4. My First Commit

So this is where things get interesting.  Honestly I fumbled around the client getting use to it for about 60 minutes before really doing anything remotely useful.  Perhaps it is a bad habit, but I tend to dive straight in, minimally read any directions and then proceed to screw things up.  This is exactly what I did on this homework assignment, but I learned a bunch along the way.  Turns out what I learned can be summarized by the Tutorial presented in the client articulating the GitHub Flow:

GitHub Flow

Make a New Branch – the default branch for a given repository is called master, and I have been told by many not to edit the master branch directly.  So created a new branch called ‘dev’ from the ‘master’ branch of my PowerShell repository on GitHub.

dev branch

Make Changes – Having the new ‘dev’ branch open, I can now add some my script – Create AD Groups.ps1.  A simple 7 line script that creates some Active Directory Groups, assigns them a Name and places them in specific OU.  Once the script is added into the dev branch, I simply then commit it to dev.

Create AD Groups

Open a Pull Request – once committed to the dev branch, then a pull request must be initiated to have it merged into the master branch.  This is one of the beautiful things about Git to help keep items under version control and allow for items to be merged from different branches into the master.  I am pulling from dev into the master branch, and as you can see my Pull Request was successful.

Pull Request

Succesfull Pull Request

Time to view it on by GitHub account, and I now have a new Create AD Groups.ps1 powershell script to share with the world.

Powershell Added

Skip to toolbar