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
- Using PowerShell to check your laptop’s battery health
- Getting started with secret vaults in PowerShell
- PowerShell Gallery: A great free resource for finding scripts
- Using JSON with PowerShell: A guide for IT professionals
- Reading text files with PowerShell and Linux bash shell
More Quick Tips articles
- Using Azure DevOps Repos in your Azure Cloud Shell
- Restarting your Azure Application Gateway with PowerShell
- Renaming your repos in Azure DevOps
- Visual Studio Code keyboard shortcut to manage your code
- Using Azure ephemeral disks when provisioning VMs with ARM