In the day-to-day work in IT, we often need to deal with manipulation of massive resources, and often this task ends up becoming difficult, especially if you are not very familiar with PowerShell cmdlets, after all the PowerShell has approximately 4000 cmdlets. Well, thinking about it, the Microsoft team created this incredible tool that is undoubtedly here to stay, Az-Predictor.
What is Az-Predictor?
Az-Predictor, an intelligent command completion module for Azure PowerShell. Az-Predictor helps our Azure developers/administrators find the cmdlet they are looking for efficiently, identify the required parameters quickly, and experience fewer errors
Of course it is possible to use the auto-complete feature already built into the PowerShell (by pressing the TAB), so that the command is automatically completed by the PowerShell, but Az-Predictor is a few steps beyond that, as the tool will not only complete the cmdlet , but also suggest all the parameters that need to be configured, ie Az-Predictor will basically do all the work based on prediction using all the documentation pages already available and the user leverage in PowerShell.
The idea behind this amazing tool is to assist in the correct syntax of commands and parameters based on AI prediction suggesting all commands to be used, including letting you use historical cmdlets, ie cmdlets already used previously.
Getting started with preview 3 (Keep in mind that at the time of this post we are talking about a preview version, so by the time you read this post there may already be a new update or a different way to install the product.)
- If you have installed the first preview:
- Close all your PowerShell sessions
- Remove the Az.Tools.Predictor module
Install PowerShell 7.2-preview 3 – Go to: https://github.com/PowerShell/PowerShell/releases/tag/v7.2.0-preview.3
Select the binary that corresponds to your platform in the assets list.
Launch PowerShell 7.2-preview 3 and Install PSReadline 2.2 beta 2 with the following:
Install-Module -Name PSReadLine -RequiredVersion 2.2.0-beta2 -AllowPrerelease
More details about PSReadline: https://www.powershellgallery.com/packages/PSReadLine/2.2.0-beta2
Install Az.Tools.Predictor preview 3
Install-module -name Az.Tools.Predictor -RequiredVersion 0.3.0
More details about Az.Tools.Predictor: https://www.powershellgallery.com/packages/Az.Tools.Predictor/0.3.0
Enable Az Predictor
Enable-AzPredictor –AllSession (This command will enable Az-Predictor in all further sessions of the current user.)
Enable the list view mode (Optional) – Believe me, you want to enable this!
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.
OK, now that we know how to make this amazing tool work, let’s have some fun.
Start by typing known commands and see how Az-Predictor starts trying to predict what you want to achieve based on your history and documentation already available. It’s pretty cool!
See the example below, I just typed “set” and see how many possibilities Az-Predictor “suggested”, cool isn’t it?
If you use the up and down arrow keys on the keyboard you can choose the command you want to use as if you have a drop down menu,
If you use the up and down arrow keys or you can choose the cmdlet you want to use as if you have a drop down menu, also if you use the right arrow your cmdlet will be completed by Az-Predictor based on the cmdlet that you “selected”, and finally, if you want/need to change parameters of the cmdlets presented, press Alt+A and you start to select each changeable parameter of the command.
See in the command below what happens if I press Alt+A
You can explore at will and try many other possibilities. I hope you enjoyed it, see you soon!