CLI for Microsoft 365 PowerShell Predictor is a PowerShell module that helps you navigate the cmdlets and parameters of CLI for Microsoft 365 in PowerShell. It provides suggestions for command completion when using CLI for Microsoft 365 in PowerShell.
CLI for Microsoft 365 PowerShell Predictor uses the subsystem plugin model available in PowerShell 7.2. This updated version requires PSReadLine 2.2.2 or higher to display suggestions.
Required configuration for CLI for Microsoft 365 PowerShell Predictor:
- PowerShell 7.2 or higher
- PSReadline 2.2.2 or higher
Install the latest version of PSReadLine:
Install-Module -Name PSReadline
Enable predictions from history and plugins
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Enable list view:
Set-PSReadLineOption -PredictionViewStyle ListView
To install the CLI.Microsoft365.PowerShell.Predictor PowerShell module run the following
Install-Module -Name CLI.Microsoft365.PowerShell.Predictor
To import the CLI.Microsoft365.PowerShell.Predictor PowerShell module for all sessions,
- Open the PowerShell profile file in a text editor
notepad $PROFILE
- Add the following in the end
Import-Module -Name CLI.Microsoft365.PowerShell.Predictor
To import the CLI for Microsoft 365 PowerShell Predictor module in the current session run the following
Import-Module -Name CLI.Microsoft365.PowerShell.Predictor
Once imported, start typing a CLI for Microsoft 365 cmdlet (e.g. m365 spo app
) and see the predictions loading.
By default the module uses Contains
search i.e. it shows predictions that starts with the input entered. This can be changed to StartsWith
by using the following cmdlet
Set-PnPPredictorSearch -Method StartsWith
The module then needs to re-imported.
StartsWith
- as per the name shows predictions that start with the entered input.
The predictions are based on the CLI for Microsoft 365 version installed on the machine. When a new version of CLI for Microsoft 365 is installed then the predictions are automatically updated when the module is imported or can be updated by running the following function
Update-CLIMircosoft365Predictions $(m365 version).replace('v', '').replace('"', '')
Once installed and enabled, CLI for Microsoft 365 PowerShell Predictor is loaded in the PowerShell profile. To uninstall the CLI.Microsoft365.PowerShell.Predictor module:
-
Close all PowerShell sessions including VS Code.
-
Launch a PowerShell session with no profile.
pwsh -noprofile
-
Uninstall CLI for Microsoft 365 PowerShell Predictor
Uninstall-Module -Name CLI.Microsoft365.PowerShell.Predictor -Force
-
Close PowerShell