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

Diebold Nixdorf ATMs targeted by jackpotting attacks

ATM manufacturer Diebold Nixdorf says its European machines are being hit by jackpotting attacks, where…

13 hours ago

Allow a home computer to connect to your Azure SQL server/database

In these days where remote computing has become crucial, you can connect your home computer…

16 hours ago

Migrating to Microsoft 365? Get the ball rolling with a trial tenant

Many companies still using Exchange Server are thinking of moving to Microsoft 365. You can…

19 hours ago

wpDiscuz WordPress plugin: Critical vulnerability found and patched

Users of the wpDiscuz interactive comment WordPress plugin should implement a new patch as soon…

2 days ago

Data lifecycle management: Policies and procedures for security and compliance

With the amount of electronic information consistently growing, data lifecycle management is crucial for compliance…

2 days ago

Deploy Windows from the cloud to on-premises hardware? Yes, you can

Wouldn’t it be nice if you could deploy Windows from the cloud while sipping an…

5 days ago