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.
More PowerShell Basics articles
- Adding custom error messages to your PowerShell scripts
- Multilingual PowerShell scripts: A must for multinational organizations
- Reading text files the easy way with PowerShell and Linux bash shell
- Managing Azure Windows Virtual Desktop using PowerShell
- Conquer the world with PowerShell global variable
More Quick Tips articles
- Allow a home computer to connect to your Azure SQL server/database
- Removing Azure root-level permissions using PowerShell
- Delete Microsoft Teams cache fast with this PowerShell one-liner
- Azure Charts: If you’re not using this cool feature, you should be
- Azure Portal Managed View: Finally, a site for sore eyes