Azure Powershell on linux on windows

In the Windows 10 Anniversary update you’re able to install the “Windows Subsystem for Linux”, see the Bash on Ubuntu on Windows blog.

Then in August we announced that Powershell had been opensourced and available on linux : https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/.

The version of Ubuntu that gets installed is 14.04 – which is supported by Powershell. So obviously the first thing you’ll want to do on your Windows 10 OS, is install Bash then Powershell and then the Azure module for Powershell. If only for a change of scenery and a bit of script-inception.

Installing Azure Powershell on Linux, in Windows

Using the Azure Billing API with Powershell

Once you’ve got an Enterprise Agreement with Microsoft Azure, you’ll probably want to know how much you’re spending.

As with everything Azure, you’re better off forgetting the UI and using Powershell.

Unfortunately, the billing API doesn’t return detailed information in a Json or xml format – it is a long string delimited by commas and linebreaks.

Before we can do anything with the detailed data we get from the API we need to clean it up into a powershell object.  Once we have a usable object to work with then we can start playing with the billing data.

In the example below, I’ve used the sample data account (Enrollment #100), just plug in your own enrollment number and the access key from the Azure Enterprise Site and you’ll be away.
For full documentation on the EA API, you can find the API guide here

Convert a Powershell hashtable to object

I’ve struggled on a few occasions of being lumbered with a hashtable that i’d created for whatever reason (usually because it’s so damn quick and easy).
Having my roots in OO development, I inevitably want to start dealing with objects at some point.

Long story short, here you go 🙂

Using the Statuscake API with Powershell

Having set up a few URL monitors with Statuscake, I needed to get the data out to start playing with it in Microsoft Excel/PowerQuery.
There are 3 sets of data that i’m extracting with the script below.

    Location data
    Test definition data
    Test Performance data

On top of the basic API calls to Statuscake I wanted to enrich their Location data with actual Geo data that could be used in a BI visualisation. For this i’m using FreeGeoIP.

Powershell function to add script to the profile

I’m currently in the middle of learning powershell; More specifically, on day 4 of the Microsoft 10325a Automating Administration with Windows Powershell 2.0.

With my coding background, i’ve tended to write most of the script inside functions to try and promote reuse.  I’ve found that maintaining a library of functions to be a bit of a headache so ended up writing the function below.  It’s by no means perfect (lets face it, PoSH is a little new to me currently… lets see how long before v2 makes it onto my blog), but it does the job.