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.

Azure Automation

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top