{"id":20018,"date":"2023-07-06T11:24:36","date_gmt":"2023-07-06T19:24:36","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=20018"},"modified":"2023-08-24T10:13:29","modified_gmt":"2023-08-24T18:13:29","slug":"what-are-feedback-providers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/what-are-feedback-providers\/","title":{"rendered":"What are Feedback Providers?"},"content":{"rendered":"<p>We introduced a new experimental feature back in PowerShell v7.4.0-preview.2+ called\n<code>PSFeedbackProvider<\/code>. This blog outlines what this experimental feature is, how to use it and\ndescribes different feedback providers we have already created.<\/p>\n<h2>Installing the PowerShell Preview and enabling Feedback Providers<\/h2>\n<p>You can install the latest 7.4 preview via our GitHub page <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/releases\">here<\/a>. If you are on Windows you can\ndownload via the Microsoft store <a href=\"https:\/\/www.microsoft.com\/store\/productId\/9P95ZZKTNRN4\">here<\/a>.<\/p>\n<p>Unless configured differently, the previews should have all experimental features enabled by deafult\nbut in case they are not enabled you can check and enable them by using the following commands:<\/p>\n<p>Checking experimental features enabled:<\/p>\n<pre><code class=\"language-powershell\">Get-ExperimentalFeature<\/code><\/pre>\n<p>Enabling experimental feature:<\/p>\n<pre><code class=\"language-powershell\">Enable-ExperimentalFeature -Name PSFeedbackProvider<\/code><\/pre>\n<p>You will also have to enable the experimental feature <code>PSCommandNotFoundSuggestion<\/code> to get enable\nthe built-in feedback provider.<\/p>\n<pre><code class=\"language-powershell\">Enable-ExperimentalFeature -Name PSCommandNotFoundSuggestion<\/code><\/pre>\n<p><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note<\/strong><\/p> You must restart your PowerShell session to enable experimental features.<\/div><\/p>\n<h2>Why have we created Feedback Providers<\/h2>\n<p>After we created PowerShell Predictive IntelliSense, we realized that no matter how hard we can try\nto be &#8220;preventative&#8221; of errors, they will still occur. This made us think there was a better way to\ngive the users more feedback to their errors so they could recover quicker from them.<\/p>\n<p>After prototyping and seeing how great it could work for errors, we got thinking that maybe we can\nhelp inform and teach users better practices to the shell and thus we expanded feedback providers to\nsuccessful executions.<\/p>\n<h2>What are Feedback Providers?<\/h2>\n<p>Feedback Providers are PowerShell modules that utilize the <code>IFeedbackProvider<\/code> interface to give\nfeedback and suggestions after the shell users have attempted to execute something. Feedback\nproviders can trigger upon three different interactive scenarios:<\/p>\n<ul>\n<li>Errors<\/li>\n<li>Success<\/li>\n<li>Comments*<\/li>\n<\/ul>\n<p><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note<\/strong><\/p>*As of August 2023, comments are no longer supported triggers for feedback providers<\/div><\/p>\n<p>This means after the user has hit enter, Feedback Providers can trigger and know what scenario the\nuser has faced.<\/p>\n<h3>Built-in Feedback Provider<\/h3>\n<p>We have created a built-in feedback provider named <code>General<\/code>. This triggers on the <code>CommandNotFound<\/code>\nexception error and gives the user suggestions on what command they may have meant to type from list\nof commands already installed in the users <code>$env:PATH<\/code>. Both native commands and PowerShell cmdlets\nwill be suggested if they are installed.<\/p>\n<p>You have may seen something similar to this before in previous versions of the\n<code>PSCommandNotFoundSuggestion<\/code> experimental feature. We have given the UX an upgraded and turned this\ninto a feedback provider!<\/p>\n<p>This is the old <code>PSCommandNotFoundSuggestion<\/code> experience:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20014\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework.png\" alt=\"Image SuggestionFramework png\" width=\"2840\" height=\"576\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework.png 2840w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework-300x61.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework-1024x208.png 1024w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework-768x156.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework-1536x312.png 1536w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/SuggestionFramework-2048x415.png 2048w\" sizes=\"(max-width: 2840px) 100vw, 2840px\" \/><\/a><\/p>\n<p>This is the same feature but with the new feedback provider model:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-20021\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1-300x65.png\" alt=\"Image CommandNotFoundFeedbackProvider\" width=\"1278\" height=\"277\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1-300x65.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1-1024x223.png 1024w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1-768x167.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/CommandNotFoundFeedbackProvider-1-2048x446.png 2048w\" sizes=\"(max-width: 1278px) 100vw, 1278px\" \/><\/a><\/p>\n<h2>Command-Not-Found Feedback Provider<\/h2>\n<p>We have created an additional feedback provider that we call the <code>command-not-found<\/code> feedback\nprovider. This utilizes the <code>command-not-found<\/code> utility tool that is defaulted on Ubuntu systems.\nThis feedback provider will trigger when the user has attempted to execute a command that is not\ninstalled on the system but will give the user suggestions on how to install the command on their\nsystem using <code>apt<\/code>. This is only compatible with Linux systems where the <code>command-not-found<\/code> utility\ntool has been installed.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/FeedbackProvider-3.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20028\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/FeedbackProvider-3.gif\" alt=\"Image FeedbackProvider\" width=\"1089\" height=\"704\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Another thing we did with this feedback provider is that we have it subscribed to the\n<code>ICommandPredictor<\/code> interface so that it can give it suggestions directly to PowerShell Predictive\nIntelliSense. This way as you start typing a suggestion, you can more quickly accept the suggestion.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20017\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound.png\" alt=\"Image commandnotfound png\" width=\"1934\" height=\"766\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound.png 1934w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound-300x119.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound-1024x406.png 1024w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound-768x304.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2023\/07\/commandnotfound-1536x608.png 1536w\" sizes=\"(max-width: 1934px) 100vw, 1934px\" \/><\/a><\/p>\n<p>We have open sourced this feedback provider so you can take a look at how we have implemented it\n<a href=\"https:\/\/github.com\/PowerShell\/command-not-found\">here<\/a>. You can install this feedback provider from the PowerShell Gallery via this command:<\/p>\n<pre><code class=\"language-powershell\">Install-Module -Name command-not-found<\/code><\/pre>\n<p>Or if you are using the latest version of PSResourceGet, you can use this command:<\/p>\n<pre><code class=\"language-powershell\">Install-PSResource -Name command-not-found<\/code><\/pre>\n<p>You will need to import the module to enable the feedback provider:<\/p>\n<pre><code class=\"language-powershell\">Import-Module -Name command-not-found<\/code><\/pre>\n<p>We recommend you save this in your PowerShell <code>$PROFILE<\/code> so that it is always available to you.<\/p>\n<h2>What&#8217;s next with Feedback Providers?<\/h2>\n<p>We are still under rapid development with feedback providers so there may be changes to them in the\nfuture! Due to the changes we are doing to the feedback provider, we will be publishing\ndocumentation on how to create your own once we have finalized some design changes for creating the\nproviders.<\/p>\n<p>In the meantime if you have any ideas on how we can make this experience best work for your\nPowerShell workflow, please let us know in the <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\">issues tab<\/a> of our PowerShell repo!<\/p>\n<p>We are excited to be sharing more about feedback providers in the near future.<\/p>\n<p>Thanks<\/p>\n<p>Steven Bucher<\/p>\n<p><!-- Link references --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an introduction to the concept of feedback providers in PowerShell. What they are, how to use them and why we are implementing them.<\/p>\n","protected":false},"author":98569,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[248],"class_list":["post-20018","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-powershell","tag-powershell","post_format-post-format-image"],"acf":[],"blog_post_summary":"<p>This is an introduction to the concept of feedback providers in PowerShell. What they are, how to use them and why we are implementing them.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/20018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/98569"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=20018"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/20018\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=20018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=20018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=20018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}