Getting started with the AZ Predictor PowerShell module for Azure
Tags: azure, powershell
Published: 2020-12-01 21:48:16

When using the Azure module in interactive mode, you can feel the frustration. There are more than 4000 cmdlets in the Azure Module, and it continues growing. Each of these cmdlets has a series of parameters and parameters set, you have to remember in order to make them work. You cannot expect someone to know them perfectly. It can be a complex world, even for the most experienced peoples.
For example, there are, at this time, 184 cmdlets for the Azure Application Gateway resource.

You can make the test.

```powershell
Get-Command -name *applicationgateway* | measure-object | select-object count
``` 

To work with the Application Gateway, you will need to navigate between your shell windows and [Microsoft Doc]( https://docs.microsoft.com/en-us/powershell/module/az.network/?view=azps-5.1.0#application-gateway?WT.mc_id=AZ-MVP-5003620) and your shell. 

PowerShell gives you a command completion by type the first letters of a cmdlet and the TAB touch. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/71wd8kqzmk5xeu330dce.png)

But it doesn't solve all our puzzles on how to type a cmdlet with the needed parameters?

The new AZ Predictor is here to solve this problem. This module is a tool to help users to navigate on cmdlet syntaxes. It can help black belt PowerShell users as well as beginners to have a better command line practice with the Azure module.

This module is available on all platforms supported by PowerShell 7.1, Windows, various Linux platforms, and MacOS 10.13 and up. It uses the predictive IntelliSense feature from the PSReadline module version 2.2 beta 1. To provide suggestions to the IntelliSense feature, the new AZ Predictor module makes API calls, so Internet access is needed.

To install the module, you need to update your PowerShell 7 version to 7.1 and install the version 2.2.0 Beta1. 

```powershell
Install-Module PSReadline -AllowPrerelease 
```

Then you can install the Az Predictor module. 

```powershell
Install-Module -Name Az.Tools.Predictor
```

After this, you will need to stop your PowerShell session by closing the terminal windows used to install the two modules. 

After opening a new PowerShell session, you can use the predictor module. 

First import the module

```powershell
import-module Az.Tools.Predictor
```

Then enable the prediction option in the PsReadline module

```powershell
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
````
After that, you will need to choose how to see your predictions. There are two options, InlineView and ListView

The InlineView option presents the plausible completion of a command you type in a terminal session. 
For get-AzApplicationGateway 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vz3tv7gr5jti9m3de129.png)

The ListView, will give you a list of suggestion based on what you typed, it includes elements from your history, things you typed in the past, and predictions from API.

For the same cmdlet

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/n3jtpbdq45byi20u63ig.png)

You can select any of the suggestions

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gmfjy4bfkxp8f49ew01v.png)

To change the option 

```powershell
Set-PSReadLineOption -PredictionViewStyle InlineView|ListView
``` 




For a long PowerShell session, you will find the InlineView less intrusive, as it will not present a long list of options each time you type a command in your terminal. 
But in an expletory mode, the ListView option can help to solve problems you may have with a cmdlet you don't know well.