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
- Which type of PowerShell loop should you be using?
- Working with CSV files in PowerShell
- Reading and extracting values from XML files with PowerShell
- Working with dates in PowerShell revisited
- PowerShell regular expressions: Making string evaluation easier
More Quick Tips articles
- New from Microsoft: Azure Security Center onboarding guide
- Fixing Azure Key Vault when moving to a different tenant
- Restore Azure Key Vault using just two PowerShell cmdlets
- This overlooked feature in Visual Studio Code can speed release time
- Enabling Front Door managed certificates in Azure: Status update