Posts by Year

2024

Converting Azure DevOps Classic Release deployment pipelines to YAML

16 minute read

I recently migrated some Azure DevOps Classic Release deployment pipelines to YAML. There’s obvious benefits to storing your pipelines as code: they become an artifact in source control that can evolve and change as the code they build or deploy does, and you have the benefits of version history and maintaining the pipelines via pull requests. However I also found that I could use logic and expressions to make the pipelines more efficient and easier to maintain and that through templating could easily connect the pipelines together to form what I humorously dubbed the “super pipeline” (but ...

Monitor and manage your Azure cloud costs with a little help from PowerShell

13 minute read

Should cloud computing be illegal? Probably not, but it is incredibly easy to get started, equally difficult to stop, and before you know it you could be selling your grandmother just to afford one more month of that delicious compute. Hopefully your circumstances never get that dire, but I’ve seen plenty of companies entrench themselves into the highly addictive world of automated, scalable infrastructure, but then struggle to understand the often-astronomical monthly bill.

Perform Currency Conversions with PowerShell

7 minute read

I’ve recently been working on a PowerShell module for exploring Azure costs and while doing so added some functionality to allow the costs to be converted between different currencies. It occurred to me that this functionality would be useful as a module of its own, and when I searched around I didn’t find too many recent examples for the same. As such I’ve now developed and published a module in the PowerShell Gallery and on GitHub called CurrencyConverter.

Back to Top ↑

2023

Back to Top ↑

2022

Changelog Driven Deployments

3 minute read

A changelog is a useful addition to any project, as it provides users and contributors with a summary of notable changes between each release. One way to ensure you always update your changelog as part of any new release is by making it part of the the automated deployment process. This blog post describes how I’ve implemented changelog driven deployments for the PowerShell modules I maintain in GitHub.

Back to Top ↑

2020

ARM Deployment “JToken type is not valid” error

1 minute read

I have recently added tasks in to our Azure DevOps ARM template deployment pipeline to run the new -WhatIf parameter on the New-AzResourceGroupDeployment to preview the changes an ARM deployment will make, per this guide:

Back to Top ↑

2018

Deploying Influx and Grafana on Windows with Terraform

11 minute read

I have previously blogged about how you can use Influx, Grafana and PowerShell to build and populate metrics dashboards for visualising data from multiple sources. This blog post details how you can use Terraform to quickly and easily deploy Grafana and Influx on a Windows instance in AWS as a proof of concept implementation of these tools.

Copy files with hash difference via PowerShell

6 minute read

This blog post details a PowerShell Core compatible cmdlet that I have authored named Copy-FileHash that you can use to copy modified files from one path tree to another. The cmdlet determines which files have different contents by calculating their hash values through the Get-FileHash cmdlet. This might be useful if you need to copy just files that have been modified between two paths and aren’t able to rely on the modified date of those files to determine which have changed.

Adding a code coverage badge to a PowerShell project

6 minute read

This blog post describes how you can add a code coverage badge to the readme.md of your PowerShell projects in Github as well as have them automatically updated with the current coverage percentage via your Continuous Integration pipeline (if you’ve implemented one).

Watch for changes with PowerShell

6 minute read

I recently needed to make a change to the membership of an Active Directory group which was enforced via Puppet. While waiting for the Puppet manifest to apply I used Get-ADGroupMember in PowerShell to check if the change had taken effect. Finding that it had not, I then wrote a crude loop to continually check the group membership until it changed. It occurred to me that this kind of functionality might be useful as a cmdlet and as such I have created Watch-Command. This blog post details how it works as well as some inventive but controversial design decisions I made.

Keep PowerShell Core updated on Windows with Chocolatey

2 minute read

PowerShell Core is the cross-platform version of PowerShell that runs on Windows, Mac and Linux. If you are not familar with it, check out my previous blog post on the topic. It’s likely that PowerShell Core will see more regular releases than we’ve had historically with Windows PowerShell. While you will be able to download the .msi installer for these releases to update your version, this blog post covers how can use the Windows package management tool Chocolatey to manage your upgrades instead.

Using Puppet Classes, Roles, Profiles and Templates

11 minute read

This post explores the Puppet topics of Classes, Roles and Profiles as well as how to utilise Puppet Template files. The class keyword is a key Puppet building block. There are various different ways to utilise the class keyword and these are explored below.

Using Puppet Modules, Forge and r10k on Windows

10 minute read

This blog post explores the topic of Puppet Modules for packaging and sharing code. It also looks at how you can use Puppet’s public module repository Forge to find existing modules and how you can use the r10k module management tool to update, manage and maintain them on your machines.

Puppet Variables, Expressions, Facts and Hiera on Windows

7 minute read

This post is a continuation of my earlier Getting Started with Puppet on Windows post (although most of the information in this post is OS agnostic). This post explores how you can make your Puppet manifests more dynamic via the typical programming constructs of variables, expressions, conditions and iteration. It also covers Puppet’s Facter tool (for simplifying the interrogation of system info) and Hiera mechanism (for separating configuration data from your code).

Getting started with Puppet on Windows

11 minute read

This blog post describes some initial steps you can take to learn Puppet, particularly to control Windows machines. I’m currently learning Puppet via the Puppet 5 Beginners Guide (Third Edition) book by John Arundel.

A PowerShell Tool Scorecard

11 minute read

This post contains a PowerShell tool-making scorecard: a series of short questions to assess whether your custom cmdlet/function/tool is following some (generally considered) best practice design choices.

PowerShell Core 6.0

5 minute read

PowerShell now comes in two flavours, (Vanilla) Windows PowerShell and PowerShell Core (..Rocky Road? ice cream flavour TBD). PowerShell Core is a version of PowerShell built on top of .NET Core. The GA version of PowerShell Core is due to be released on the 10th January and Release Candidate versions have been available for some time.

Intermittent Isilon write failures due to SMB3 Multichannel setting

7 minute read

I recently resolved an issue with our Isilon storage cluster that was causing file writes to be interrupted and fail. While diagnosing the issue I discovered that (intriguingly) the disruption was occurring at (almost) exact 10 minute intervals. Any in progress write operation occurring at that interval would fail.

Back to Top ↑

2017

Managing SSRS Subscriptions with PowerShell

8 minute read

I was recently tasked with investigating how we could store the configuration of our SQL Server Reporting Services report subscriptions in a source control and then automate the process of (later) configuring them in one or more new SSRS servers.

TILFMOL #4 - PowerShell Jobs

4 minute read

This is the fourth and final part of a short series of posts about things I discovered by reading the excellent Learn PowerShell in a Month of Lunches book (recently released in 3rd edition) as a not quite beginner.

TILFMOL #3 - PowerShell Remoting

4 minute read

This is part three of a short series of posts about things I discovered from reading Learn PowerShell in a Month of Lunches (recently released in 3rd edition).

TILFMOL #2 - PowerShell Help

7 minute read

This is part two of a short series of posts about things I discovered or had clarified by reading the excellent Learn PowerShell in a Month of Lunches book (recently released in 3rd edition).

TILFMOL #1 - The PowerShell Pipeline

4 minute read

As introduced in my previous post, this is part one of a four part series that documents some things I discovered or had clarified by reading the excellent Learn PowerShell in a Month of Lunches book (recently released in 3rd edition).

Learn PowerShell in a Month of Lunches

2 minute read

I got started with PowerShell thanks to the encouragement and enthusiasm of a friend and former colleague. Following that, I’ve largely developed my knowledge through the standard combinations of trial + error + googling and more recently (as is evident) by doing my best to engage with and give back to the community.

Issue uploading Pester test results in to AppVeyor

2 minute read

While experimenting with AppVeyor to add Continuous Integration to my PowerShell projects (more detailed blog post to follow) I encountered a bug that meant that the Pester test results (uploaded via the NUnit formatted results file) were not appearing in the “Tests” tab of my AppVeyor project.

Create dynamic PowerShell functions with Parameter Sets

5 minute read

While developing a PowerShell function to query the API of the webcomic XKCD I decided to explore and implement Parameter Sets. These allow you to provide your users with different sets of parameters based on different use cases (assuming you have multiple use cases), which as a result provides a more dynamic set of functionality from a single cmdlet.

Back to Top ↑

2016

A Slack Slash Command using Powershell Azure Functions

7 minute read

In my previous post I talked about creating a Powershell function to lookup terms in a large internal glossary I had collated. This post takes this a step further and creates a custom slash command integration in a Slack chatroom that calls out to a Powershell-based Azure Function to query my (now) Azure hosted glossary.

A Powershell cmdlet for looking up internal terms in a glossary

2 minute read

I’ve recently started a new role and as a result I have a lot of new business terms and acronyms to get to grips with. A list of about 50 of these were handed to me on my first day which was really helpful, but when I searched around the intranet and various other sources of documentation I found there were many more.

Operational Testing for Antivirus: Validating Symantec Endpoint Protection with Pester

2 minute read

This post contains an operational validation test for Symantec Endpoint Protection (SEP) using the Pester testing framework module with Powershell. It performs a few basic checks to ensure SEP is running and healthy. It is intended as a starting point and could be developed further. Your individual requirements will likely vary depending on how you have SEP configured and deployed in your environment.

Getting started with Pester (for operational testing)

6 minute read

This is a guide for anyone new to the Pester testing framework module for Powershell who would like to learn how Pester works in order to maintain or create Pester test scripts that are used for operational testing.

Getting started with Powershell

8 minute read

This post is a list of resources and tips to help anyone new to Windows Powershell in getting started with the language. If Powershell is completely new to you, I recommend you review all of the listed resources. If you find other great resources along the way, please feel free to comment below and i’ll contribute them to this list.

Cleaning up paused devices from PRTG with Powershell

9 minute read

One of our AWS based products uses auto-scaling and when new instances are deployed a script automatically creates sensors for them in PRTG (our monitoring tool). When the instances are scaled down/terminated there is not a script that automatically removes them from PRTG (in part so that we can temporarily retain the monitoring history). As a result, our monitoring over time can become cluttered with redundant paused devices, so a script was needed to automate the process of clearing those down.

Using Test-NetConnection to diagnose network connectivity

3 minute read

Powershell version 4 and Windows 8.1 / 2012 R2 introduced the Test-NetConnection command as a tool for performing network connectivity tests with Powershell. Test-NetConnection allows you to perform ping, traceroute and TCP port tests and from Windows 10 and Server 2016 onward introduces the ability to do “Diagnose Routing” tests with the same cmdlet.

Get uptime from multiple servers with Powershell

2 minute read

The following script can be used to get the current uptime from a collection of servers in Active Directory using WMI. I used it as a way to audit our estate, keen to understand how long servers have been operational for, in part to identify those which were potentially not routinely receiving Windows Updates.

Synchronising Git repositories to disk with Chef

5 minute read

My team has an ever-growing collection of administration scripts and tools which are organised and maintained within a number of Git repositories. In order to ensure that the copies of these scripts in production always reflect the Master branch in Source Control we set up a Chef cookbook to synchronise the repositories to a network share in the environment. This post details how this functionality was developed and deployed.

Testing Active Directory with Pester and Powershell

4 minute read

Irwin Strachan published a Pester script for Operational Testing of Active Directory back in April which I was keen to try out. Afterwards I extended the script to add some additional health checks of Active Directory and this post explains how the resultant combination of our work can be used to validate your Active Directory.

Handling Powershell exceptions with Try..Catch..Finally

5 minute read

Recently while writing a script I expected two commands I was calling to throw exceptions because I expected my script to be unable to remotely connect to some of my servers. Initially I handled the result of these exceptions with If..Else blocks, but it felt like a Try..Catch might be more appropriate.

Automate yourself a better job with Powershell

4 minute read

The phrase “automate yourself out of a job” is too easily misinterpreted as a negative. Without any context it’s possible to view it as to mean you shouldn’t automate things. If you do you’ll end up unemployed or could make others unemployed. In IT at least, this is unlikely to be true. Powershell is 10 years old later this year and if you’re not using it, here’s why you should.

Containers in Windows Server 2016 TP5

7 minute read

I’m just starting to get my head around the concept of Containers and as such decided to take Windows Server 2016 Technical Preview 5 for a spin, which includes Docker Containers as a feature. It’s potentially worth being more explicit here (for anyone not aware) that this isn’t Microsoft’s version of Containers, this is actually Docker baked in to Server 2016. That’s a pretty cool move on Microsoft’s part.

Installing Windows Server 2016 TP5 Server Core

2 minute read

Previously I covered performing the installation of Windows Server 2016 Technical Preview 5 in to a desktop VM with the Desktop Experience (GUI) mode enabled. This post covers the installation of the GUI-less Server Core mode and subsequently how to manage and maintain it.

Installing Windows Server 2016 TP5 (Technical Preview 5)

3 minute read

On the 27th of April 2016 Microsoft released Technical Preview 5 of Windows Server 2016. I was keen to see the new version in action, particularly since attending a talk recently on Windows Containers, which have been a feature available for testing since TP3. I am going to explore Containers in a later post, but here i’m going to cover how I chose to get the OS up and running, as when I came to do it I struggled to find a recommendation on where to test it. 1. Choose a Hypervisor

A PowerShell stopwatch for your Profile.ps1

2 minute read

Boe Prox blogged/tweeted recently about how you can start a stopwatch in PowerShell with one line using the command [System.Diagnostics.Stopwatch]::StartNew(). While there are plenty of other ways to measure time in PowerShell (e.g measure-object, new-timespan), I could see an adhoc stopwatch being useful on occasion. However the raw class name is a bit clunky and forgettable. Therefore as a bit of fun I have created it as a series of functions in my PowerShell Profile.ps1 with friendly names I could call when needed.

Three things you might not know about Import-module

1 minute read

In Powershell the Import-Module cmdlet allows you to extend the cmdlets available to you within your script or console. This can be official extensions, such as the activedirectory module that is included with AD Tools, or custom modules you have written yourself to group together a useful set of functions or commands. This post briefly covers a few tricks i’ve discovered about import-module that i’ve found repeatedly useful.

Back to Top ↑