Azure PowerShell is one of my preferred ways to build automation and manage Microsoft Azure. However, as Damien Caro (Microsoft Program Manager) mentions, the Azure PowerShell modules has over 4,000 cmdlets and, on average, ten parameters per cmdlet. This can make it hard to find the right cmdlet and parameter for what you want to do. To make this easier, the team created the Az Predictor, an intelligent command completion module for Azure PowerShell. Az Predictor will help you with predictions when you run Azure PowerShell.
In the last couple of days and weeks, I started to try out the new PowerShell Predictive IntelliSense and Az Predictor, and together with the PSReadline version, and I wouldn’t work without it anymore. it kind of reminds me of the AI-supported Azure CLI command in az find.
Az Predictor helps our Azure developers find the cmdlet they are looking for efficiently, identify the required parameters quickly, and experience fewer errors.Damien Caro – Microsoft Program Manager
We worked closely with the PowerShell team to have Az be the first module that leverages this new interface and bring suggestions to the developer’s fingertips. Az Predictor takes the context of the current session into account in its suggestions. With Az Predictor’s context-aware suggestions users will be guided through the discovery of cmdlets and will not need to go to the online help as often.
Az Predictior Modes for Azure PowerShell
Inline mode – Suggestions of parameters and values will appear on the rest of the command line.
Listview mode – This will show several suggestions below the command line with the complete parameter set displayed.
Getting started with Az Predictor
Az Predictor is currently a module in preview in the PowerShell gallery. It leverages the subsystem plugin model that is available after PowerShell 7.2 and used by PSReadline 2.2.2.
You can learn more about this in my PowerShell Deep Dive reaction video.
- PowerShell 7.2 (PowerShell 7 can run side by side with Windows PowerShell 5.1)
- PSReadline 2.2.2 – Learn more about PSReadline 2.2.0
Install Az Predictor
To install and get started just follow these easy steps:
- Install PowerShell 7.2
- Install PSReadline 2.2
Install-Module PSReadline -Force
- Install Az.Tools.Predictor preview
Install-Module -Name Az.Tools.Predictor
- Import Module
Import-Module Az.Tools.Predictor -RequiredVersion 0.2.0
- Enable the plugins
- Enable the list view mode (Optional)
Set-PSReadLineOption -PredictionViewStyle ListView
If you want to load Az predictor every time you start PowerShell (and trust me you want that 😉), you can add the last three commands to your PowerShell profile.
Conclusion and Feedback
I hope this blog provides you with an overview of this awesome new module, which allows you to predict your Azure PowerShell commands. The team is currently looking for feedback so log issues, feature requests, or design changes on GitHub, and take a moment to fill this brief survey.
If you have any questions feel free to leave a comment.Last modified: February 24, 2022