What are Feedback Providers?

Steven Bucher

We introduced a new experimental feature back in PowerShell v7.4.0-preview.2+ called PSFeedbackProvider. This blog outlines what this experimental feature is, how to use it and describes different feedback providers we have already created.

Installing the PowerShell Preview and enabling Feedback Providers

You can install the latest 7.4 preview via our GitHub page here. If you are on Windows you can download via the Microsoft store here.

Unless configured differently, the previews should have all experimental features enabled by deafult but in case they are not enabled you can check and enable them by using the following commands:

Checking experimental features enabled:

Get-ExperimentalFeature

Enabling experimental feature:

Enable-ExperimentalFeature -Name PSFeedbackProvider

You will also have to enable the experimental feature PSCommandNotFoundSuggestion to get enable the built-in feedback provider.

Enable-ExperimentalFeature -Name PSCommandNotFoundSuggestion

Note


You must restart your PowerShell session to enable experimental features.

Why have we created Feedback Providers

After we created PowerShell Predictive IntelliSense, we realized that no matter how hard we can try to be “preventative” of errors, they will still occur. This made us think there was a better way to give the users more feedback to their errors so they could recover quicker from them.

After prototyping and seeing how great it could work for errors, we got thinking that maybe we can help inform and teach users better practices to the shell and thus we expanded feedback providers to successful executions.

What are Feedback Providers?

Feedback Providers are PowerShell modules that utilize the IFeedbackProvider interface to give feedback and suggestions after the shell users have attempted to execute something. Feedback providers can trigger upon three different interactive scenarios:

  • Errors
  • Success
  • Comments*

Note


*As of August 2023, comments are no longer supported triggers for feedback providers

This means after the user has hit enter, Feedback Providers can trigger and know what scenario the user has faced.

Built-in Feedback Provider

We have created a built-in feedback provider named General. This triggers on the CommandNotFound exception error and gives the user suggestions on what command they may have meant to type from list of commands already installed in the users $env:PATH. Both native commands and PowerShell cmdlets will be suggested if they are installed.

You have may seen something similar to this before in previous versions of the PSCommandNotFoundSuggestion experimental feature. We have given the UX an upgraded and turned this into a feedback provider!

This is the old PSCommandNotFoundSuggestion experience:

Image SuggestionFramework png

This is the same feature but with the new feedback provider model:

Image CommandNotFoundFeedbackProvider

Command-Not-Found Feedback Provider

We have created an additional feedback provider that we call the command-not-found feedback provider. This utilizes the command-not-found utility tool that is defaulted on Ubuntu systems. This feedback provider will trigger when the user has attempted to execute a command that is not installed on the system but will give the user suggestions on how to install the command on their system using apt. This is only compatible with Linux systems where the command-not-found utility tool has been installed.

Image FeedbackProvider

 

Another thing we did with this feedback provider is that we have it subscribed to the ICommandPredictor interface so that it can give it suggestions directly to PowerShell Predictive IntelliSense. This way as you start typing a suggestion, you can more quickly accept the suggestion.

Image commandnotfound png

We have open sourced this feedback provider so you can take a look at how we have implemented it here. You can install this feedback provider from the PowerShell Gallery via this command:

Install-Module -Name command-not-found

Or if you are using the latest version of PSResourceGet, you can use this command:

Install-PSResource -Name command-not-found

You will need to import the module to enable the feedback provider:

Import-Module -Name command-not-found

We recommend you save this in your PowerShell $PROFILE so that it is always available to you.

What’s next with Feedback Providers?

We are still under rapid development with feedback providers so there may be changes to them in the future! Due to the changes we are doing to the feedback provider, we will be publishing documentation on how to create your own once we have finalized some design changes for creating the providers.

In the meantime if you have any ideas on how we can make this experience best work for your PowerShell workflow, please let us know in the issues tab of our PowerShell repo!

We are excited to be sharing more about feedback providers in the near future.

Thanks

Steven Bucher

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Mystery Man 0

    Typo alert: “Built in” must be “built-in” (note the hyphen).

    • Steven BucherMicrosoft employee 0

      Fixed 🙂 Thanks!

Feedback usabilla icon