PowerShell Quick Tip: Consistent output in Azure Automation Accounts

I have previously made available a simple function to help show output when running PowerShell, and I called it msgbox. Recently, I was working with Azure Automation, and my goal was to make a consistent experience for the end-user. Azure Automation is slightly different than a regular PowerShell script. For starters, it does not accept write-host, thus no -foregroundcolor as well.

I adapted the function to be used in Azure Automation, and you can see the result on the image depicted below. The code for the function can be found here.

Add the code at the beginning of your Runbook in Azure Automation, and to call it, use the following syntax:

Msgbox “Info:” “Message” 0 70

Where 0 can be replaced by 1 or 2 (0 means OKAY, 1 is WARNING, and 2 is ERROR) and 70 is the number of spaces where the [ Status ] should appear.

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides of the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange, CISSP and several other certifications. Anderson contributes to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at Techgenix.com, MSExchange.org, ITPROCentral.com and Anderson Patricio.org (Portuguese).

Share
Published by
Anderson Patricio

Recent Posts

WordPress vulnerability puts 300,000 at risk for attack

A WordPress vulnerability that could affect 300,000 users has been identified and patched. By if admins don’t update, they remain…

59 mins ago

PowerShell jobs — because you have better things to do than wait

If you run PowerShell commands that take a while to complete, consider using PowerShell jobs, which will allow the command…

4 hours ago

Validating virtual networks rules in a Storage Account using PowerShell

Here’s a TechGenix Quick Tip on how to use PowerShell to retrieve a list of virtual network rules in a…

20 hours ago

Dell launches selection of new PCs, displays, and software

A line of new Dell PCs, with innovative tech capabilities like AI and 5G, are aimed at both personal and…

1 day ago

Exchange 2010 upgrade: Migrate or export mail to PST and start fresh?

If you’re on Exchange 2010, you will have to upgrade soon. And while starting from scratch with a new 2016…

1 day ago

How to repair PST files and import data back to Outlook or Office 365

If your business relies on Outlook, you can’t risk losing mailbox data because of PST files corruption. Here’s how to…

4 days ago