Avatar

Mads Moi-Aune


Get Array of Unique Objects in Servicenow

There’s no secret that the Javascript support (serverside) in ServiecNow is lacking. And today I came across another little quirk. In ServiceNow we have the ArrayUtil.unique() to get an Array of unique values, but this does not support objects. Neither does ServiceNow support Map() or Set() on the serverside, so here’s a little snippet to filter an array of objects and receive unique objects based on a object key.

Read more ...

Copy to Clipboard in Servicenow

Recently I was asked to find a way for users to easily create a string consisting of the task number and short description that they could paste into the time management software. In this short article we’re going to take a look at how we can copy something to your system clipboard from a UI Action in ServiceNow.

Read more ...

Golang: Azure Functions Blob Storage Output Binding

Lately, I’ve been setting up an Azure Function App with a custom handler written in Go. One of my functions needs to download a file from an external URL and then upload that file to Azure Blob Storage. Unfortunately, neither the documentation on Microsoft Learn or the examples on Github mentions how to use Blob Storage as output binding for custom handlers. So I decided to do a little write up on how I solved it.

Read more ...

Web requests with basic authentication in Powershell

HTTP Basic Authentication is one of many authentication schemes supported by the HTTP protocol, and is a very common option when authenticating to a web service. The basic authentication scheme is very simple and consists of generating a base64 token from your username and password seperated by a colon (:) and putting the token in an Authorization HTTP header. Let’s explore some examples in Powershell.

Read more ...

Generate Access Tokens for Microsoft Services With Powershell

As automators we often need to interact with REST API’s and if you are working with Microsoft Azure you probably found yourself dealing with several of Microsoft’s services i.e Microsoft Graph, Azure Resource Manager or Partner Center. Many of these services is supported by a Powershell module that handles authentication etc.. But I have found lately that more often than not it’s actually easier to just work with the raw REST API, especially for cross-platform development. In this article we’re going to take a look at two flows for how we can authenticate with the different services.

Read more ...

Generate Microsoft Partner Center Refresh Token

Microsoft Partner Center is a portal where you can manage all of your CSP customers and can give you a lot of access and power to do so. Therefor you should naturally have great security on the users that has access to this portal. Like MFA for example.

Read more ...

Azure Device Flow Authentication in Go

One of the usecases of Go is to create CLI tools for developers to ease their work. Often it involves creating/modifying resources or retrieving information from cloud services. In this post we’re going to setup device flow authentication against AzureAD in Go.

Read more ...

Get type definition in Powershell

Today I went back to some Powershell scripting with the Az module and it frustrated me that I wasn’t easily able to know what properties Get-AzADGroup (or any of the other Az cmdlets) returned to me without actually invoking the cmdlet. E.g I dont want to invoke New-AzADGroup just to be able to see what properties it will give me so I can use that in my script. Previously I’ve relied on IntelliSens in my editor, but it often fails, so I sought out to find a more manual solution (who would have thought..).

Read more ...

Interacting with Azure Key Vault in Go

Most times when working with API’s there some kind of documentation on how to iteract with it. Working with Azure SDK for Go is a different story. There’s almost no documentation (except the code itself). At my current job we use Azure a lot and a big part of that is Azure Key Vault. For my latest project I had to fetch some secrets from Key Vault to use in a CLI application, so I had to start digging into the source code to find how to interact with it.

Read more ...

Get changed fields in server scripts in ServiceNow

In ServiceNow you often write Business Rules or some other logic, based on fields that has been changed/updated. For the most part, this can be done via GUI, but sometimes you have to resort to some scripting. If you ever need to get which fields has been changed/updated, e.g in an advanced filter, this is how you check for it.

Read more ...

Golang: Generate Random Numbers

Here’s how to generate pseudorandom numbers in Go between to values. NOTE: You should always seed your random generator, or else it will produce the same result every time. Include this snippet at the top of your main func.

Read more ...

Golang: Format Date and Time

Most programming languages use the same layout (dd-mm-yyyy) to format date and time, but Go decided to go a different route. Below is a little cheat sheet of how to format date and time in Go.

Read more ...

Improving Powershell Profile

For years I’ve been a fan of the linux bash, with easy support for ssh-keys, colorized directory listings and git info the prompt. But at the same time, I really love Powershell. I have finally found some usefull Powershell modules that has made me switch completly to Powershell in the terminal.

Read more ...

Getting Started With Azure Functions

Azure Functions is one of Microsofts serverless services that you can setup in Azure. Being serverless means that you dont have to worry about the infrastructure and environment behind it and you will only pay for the capacity that you actually use when the function is running. Traditionally you would have a server that runs 24/7 and consume capacity. Very simplified, serverless will spin up and down as requests comes in. This means that you only have to focus on the code it should run.

Read more ...

Enable External Booking of Meeting Rooms

From time to time you might need to share one or more of your meeting rooms with external users. In this posts we’re going through three options for how you can enable this. Other options do exists (like connecting an Office 365 tenant to another and so), but this post is meant for the time you need to give temporary access or only to one or more users.

Read more ...

Powershell Extract Windows Spotlight Images

A very nice feature of Windows 10 is Windows Spotlight who serves beautiful wallpapers on your lock screen every day. It’s a shame these beautiful images are hidden in a system folder somewhere in Windows, so today I’m going to show you how you can extract these images with Powershell. You could perfectly do this manually, but since these images change periodically (haven’t found any info on when) its much easier to just run a script. Personally I run this script as a scheduled job everyday.

Read more ...

ServiceNow: Sending notifications to Microsoft Teams

Microsoft Teams support different Connections and one of the simpliest is “Incomming Webhook” which gives you a URL that you can POST to with a correctly configured JSON body and the result will be displayed in your specified channel. In this guide we’ll set this up and POST to it from Service-Now when an incident is created or updated.

Read more ...