PnP PowerShell Predictor is a PowerShell module that helps you navigate the cmdlets and parameters of PnP PowerShell. It provides suggestions for command completion when using PnP PowerShell cmdlets.
PnP 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 PnP 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 PnP.PowerShell.Predictor PowerShell module run the following
Install-Module -Name PnP.PowerShell.Predictor
To import the PnP PowerShell Predictor PowerShell module in the current session run the following
Import-Module -Name PnP.PowerShell.Predictor
Once imported, start typing PnP PowerShell cmdlet (e.g. Connect-PnPOnline
) and see the predictions loading.
The module tries to get the version of the cmdlets from GitHub based on the PnP PowerShell version on your machine. In case, it is not able to find the version of cmdlets from GitHub then it will load a set of predictions that are shipped with the module.
Hence some commands from the predictions might not be present in the version on PnP PowerShell on your machine and they might not work.
To disable this warning, set the environment vaiable PnPPredictorShowWarning
to false in your profile.ps1 file.
$env:PnPPredictorShowWarning = "false"
By default the module uses Contains
search i.e. it shows predictions that contain the input entered. This can be changed to either StartsWith
or Fuzzy
by using the following cmdlet
Set-PnPPredictorToolSearch -Method StartsWith|Contains|Fuzzy
StartsWith
- as per the name shows predictions that start with the entered input
Fuzzy
- does a Fuzzy search and returns predictions. Sometimes the results might not be as per the expectaion in this case.
To disable PnP PowerShell Predictor suggestions in the current session run the following
Disable-PnPPredictorToolSuggestions
To enable PnP PowerShell Predictor suggestions in the current session run the following
Enable-PnPPredictorToolSuggestions
Once installed and enabled, PnP PowerShell Predictor is loaded in the PowerShell profile. To uninstall the PnP.PowerShell.Predictor module:
-
Close all PowerShell sessions including VS Code.
-
Launch a PowerShell session with no profile.
pwsh -noprofile
-
Uninstall PnP PowerShell Predictor
Uninstall-Module -Name PnP.PowerShell.Predictor -Force
-
Close PowerShell