Steven Bucher, Author at PowerShell Team https://devblogs.microsoft.com/powershell/author/stevenbucher/ Automating the world one-liner at a time… Wed, 21 May 2025 15:21:09 +0000 en-US hourly 1 https://devblogs.microsoft.com/powershell/wp-content/uploads/sites/30/2024/10/Microsoft-favicon-48x48.jpg Steven Bucher, Author at PowerShell Team https://devblogs.microsoft.com/powershell/author/stevenbucher/ 32 32 AI Shell Preview 4 Release! https://devblogs.microsoft.com/powershell/preview-4-ai-shell/ https://devblogs.microsoft.com/powershell/preview-4-ai-shell/#comments Wed, 21 May 2025 15:16:13 +0000 https://devblogs.microsoft.com/powershell/?p=20814 We're excited to share the latest preview release of AI Shell that includes new features and improvements based on your feedback.

The post AI Shell Preview 4 Release! appeared first on PowerShell Team.

]]>

AI Shell Preview 4 Is here: Better macOS support, and more!

We’re excited to share the latest preview release of AI Shell that includes new features and improvements based on your feedback. This release focuses on improving the user experience by improving access to Azure OpenAI deployments, improvements to the Invoke-AIShell command, and expanded compatibility with macOS.

MacOS support improvements

We’ve made significant improvements to the macOS side car experience with iTerm2. Previously, the side car experience was unreliable and didn’t support the /code post command. Now you have a more reliable experience with feature parity with your experience on Windows. For this experience you need to run PowerShell 7 in iTerm2. For more information about PowerShell 7 on macOS, see Installing PowerShell on macOS.

AI Shell Preview 4 on mac

Support for Microsoft Entra ID

To keep password and keys secure, we’ve added support for Entra ID authentication to to Azure OpenAI instances. Now you can access your Azure OpenAI resource without storing keys in the configuration file. The following example shows how to configure Entra ID authentication:

{
  // Declare GPT instances.
  "GPTs": [
      // Declaration of an Azure OpenAI instance with EntraID authentication
      {
        "Name": "ps-az-entraId",
        "Description": "A GPT instance with expertise in PowerShell scripting using Entra ID authentication.",
        "Endpoint": "<Your Endpoint>",
        "Deployment": "<Your Deployment Name>",
        "ModelName": "<Your Model Name>",
        "AuthType": "EntraID",
        "SystemPrompt": "You are a helpful and friendly assistant with expertise in PowerShell scripting and command line."
      }
  ],

  // Specify the default GPT instance to use for user query.
  "Active": "ps-az-entraId"
}

This is the hierarchy of credentials that AI Shell will use to authenticate to Azure OpenAI:

  • EnvironmentCredential
  • WorkloadIdentityCredential
  • ManagedIdentityCredential
  • SharedTokenCacheCredential
  • VisualStudioCredential
  • AzureCliCredential
  • AzurePowerShellCredential
  • AzureDeveloperCliCredential
  • InteractiveBrowserCredential

For more information on what these particular credentials are, please see the DefaultAzureCredential reference.

Invoke-AIShell command additions

We’ve added additional parameters to the Invoke-AIShell command to allow for easier use of the side pane without leaving the left side of the screen.

  • -PostCode – This parameter allows you to post code generated from the side pane to the connected PowerShell session. It reduces the need to switch between the side pane and terminal to run the /code post command.
  • -CopyCode – This parameter allows you to copy code from the side pane without using the /code copy command.
  • -Exit – This parameter allows you to exit the side pane without using the /exit command.

Video of Invoke-AIShell Demo.

These new parameters allow you to use your terminal normally. You can inject AI generated commands without cluttering your main buffer and keep all the details and descriptions in the side pane. This is a great way to use AI Shell as side by side shell assistant! Coupled with PSReadLine Predictive IntelliSense, you can quickly and easily use AI Shell in your normal shell workflow.

Phi Silica agent

We’ve added a new experimental agent called Phi Silica. This agent uses the built-in Phi Silica model included with the latest Copilot+ PCs, allowing you to have an offline experience with AI Shell.

Note

This agent isn’t shipped with the default installation of AI Shell. To use this agent, you need to clone the repo and build the code. Follow the instructions at Locally Building AI Shell.

Phi Silica Agent

This experimental AI provider is a proof of concept that’s still under development. You should only use it for testing. Expect breaking changes in future releases.

Additional minor improvements

Here are a few additional improvements that have been made in this release:

  • Updated model information to support latest OpenAI models (#368)
  • Add /clear as an alias to the command /cls to clear console in AIShell (#370)
  • Update installation script to install the AIShell module on macOS too (#374)
  • Enhanced model management and system prompt integration in OllamaAgent (#351) (Thanks @cnupy!)

To see the full list of changes, check out the changelog in the release page.

How to install AI Shell Preview 4

To install the latest version of AI Shell, run the following command in your PowerShell terminal:

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }"

As usual we would love for you to try AI Shell and provide feedback in our GitHub repository.

Thanks so much!

AI Shell Team

Steven Bucher & Dongbo Wang

The post AI Shell Preview 4 Release! appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/preview-4-ai-shell/feed/ 1
Announcing AI Shell Preview 2 https://devblogs.microsoft.com/powershell/ai-shell-preview-2/ https://devblogs.microsoft.com/powershell/ai-shell-preview-2/#comments Fri, 28 Feb 2025 20:49:30 +0000 https://devblogs.microsoft.com/powershell/?p=20766 We are pleased to share a new preview release of AI Shell!

The post Announcing AI Shell Preview 2 appeared first on PowerShell Team.

]]>

What’s New in AI Shell Preview 2?

We’re excited to announce the Preview 2 release of AI Shell! With this update you can expect the following improvements:

  • Improved support for Azure PowerShell
  • Broader support for third party OpenAI-compatible models
  • Refactored code sample for creating an Ollama agent
  • Improved native command error handling
  • An easier way to deploy Azure OpenAI instances
  • Additional bug fixes

AI Shell Preview 3 is released!

Preview 3 has been released just two weeks after Preview 2 due to a backend issue affecting the Azure Agent. This update addresses the problem, ensuring more reliable interactions with Azure services.

Improved support for Azure PowerShell

The improvements to the azure agent are designed to reduce friction when managing Azure resources with the Azure CLI and PowerShell. The agent now offers deeper integration with Azure PowerShell, making it easier to use AI-created Azure PowerShell scripts.

  • The /replace command now supports Azure PowerShell. The agent walks you through replacement of parameter values in generated Azure PowerShell responses.
  • The agent now support Azure PowerShell authentication using the Connect-AzAccount command. Previously, the agent only supported Azure CLI authentication.

Broader support for third party OpenAI-compatibles models

With this release, the openai-gpt agent extends support to third party models that follow the OpenAI API specifications, allowing for a more flexible AI experience. Many of these models are open source tools for running SLMs and LLMs locally. The openai-gpt agent nows supports the following additional models:

To use these models, you only need to configure the endpoint, key and model name in the agent config file. The following openai.agents.config file contains example configurations for two of the new AI providers.

{
    "GPTs": [
        {
          "Name": "gpt-deepseek",
          "Description": "A GPT instance using DeepSeek v3.",
          "Endpoint": "https://api.deepseek.com",
          "ModelName": "deepseek-chat",
          "Key": "<your-deepseek-api-key>",
          "SystemPrompt": "You are a helpful assistant."
        },

        {
          "Name": "gpt-gemini",
          "Description": "A GPT instance using Google Gemini.",
          "Endpoint": "https://generativelanguage.googleapis.com/v1beta/openai/",
          "ModelName": "gemini-1.5-flash",
          "Key": "<your-gemini-api-key>",
          "SystemPrompt": "You are a helpful assistant."
        }
    ]

    "Active": "gpt-deepseek"
}

Improved native command error handling

Resolve-Error (alias fixit) now uses the screen scraper API on Windows to capture the error output of native commands. This allows AI Shell to provide better resolution of error messages that come from native commands rather than from PowerShell.

Resolve Error demo

Ollama agent improvements

We refactored the example code for the agent ollama. This example provides the basic structure that you can use to build out your own agent. The refactored code now uses the OllamaSharp library and add the ability to configure the agent using settings files.

The ollama agent isn’t shipped with AI Shell but you can build it yourself. See the instructions in the locally build the repo section of the README. Thank you @kborowinski on GitHub for this contribution!

Tools for easy deployment of Azure OpenAI instances

We added a Bicep template that deploys an Azure OpenAI instance in seconds. Using the template is much faster than manually creating an instance in the Azure portal. This template includes documentation with step by step instructions.

Additional bug fixes

There are many bug fixes in this release. For a complete list of changes, see the changelog.

How to get AI Shell Preview 2

Use the following command in PowerShell 7 to install or upgrade AI Shell:

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }"

For more information, see Install AI Shell.

Automatically start AI Shell

One piece of feedback we often hear is: How can I have AI Shell automatically start up when I open Windows Terminal?

It’s easy! Just add Start-AIShell to your PowerShell profile script. Here’s how:

  1. Open your profile in the text editor of your choice.
  2. Add the following code to the end of the file:
    if ($PSVersionTable.PSVersion -ge ([version]'7.4.6') -and
      (Get-Process -Id $pid).Parent.Name -eq 'WindowsTerminal') {
       Start-AIShell
    }

Now, AI Shell will automatically start when you open Windows Terminal.

NOTE

AI Shell only works with Windows Terminal and requires PowerShell 7.4.6 or higher.

If you need help creating a profile scripts, see about_Profiles.

Try it out and share your feedback

We would love to hear your feedback as we continue improving AI Shell. Join the discussion in our GitHub Issues and let us know how AI Shell is helping your automation workflows.

Stay tuned for future updates as we bring more AI-powered capabilities to your CLI experience. 🚀

Thanks!

Steven Bucher and Dongbo Wang

AI Shell Team

The post Announcing AI Shell Preview 2 appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/ai-shell-preview-2/feed/ 6
Microsoft Update changes for PowerShell 7 https://devblogs.microsoft.com/powershell/microsoft-update-changes-for-powershell-7/ https://devblogs.microsoft.com/powershell/microsoft-update-changes-for-powershell-7/#comments Thu, 27 Feb 2025 22:28:17 +0000 https://devblogs.microsoft.com/powershell/?p=20749 This blog outlines the expected behavior of MU releases for PowerShell 7.

The post Microsoft Update changes for PowerShell 7 appeared first on PowerShell Team.

]]>
Microsoft Update (MU) changes for PowerShell 7

It has been a while since we’ve updated folks on the latest behaviors for Microsoft Update! This post gives some background on Microsoft Update, explains our update rules, and announces our plans for updating your installs of PowerShell 7.2.

About Microsoft Update

Microsoft Update (MU) is a service that provides automatic updates for Microsoft products and services. We first started using MU in PowerShell 7.2. MU provides a convenient way to automatically update PowerShell 7, which ensures you can control your update schedule, test it against your environment, and scale across your enterprise with ease.

Enabling MU

During MSI installation, two checkboxes control update settings:

  • Enable updates for PowerShell through Microsoft Update or WSUS (recommended) Allows the system to receive updates for PowerShell 7 through Microsoft Update, Windows Server Update Services (WSUS), or System Center Configuration Manager (SCCM).
  • Enable Microsoft Update when I check for updates (recommended) Permits the system to receive updates for all supported Microsoft software, not just Windows.

We recommend that you select both options to ensure comprehensive update coverage.

If you want to set these options while installing PowerShell from the command line, you can find detailed instructions in the PowerShell documentation.

Update Availability

After we release a new PowerShell version, it can take up to two weeks before the update is available through Microsoft Update. We strive to publish the update no later than 2 weeks after the GitHub release, but there is no guarantee. There may be circumstances that delay the update. If you need the update before it’s available via MU, you can download it directly from the PowerShell Releases page on GitHub.

What is the expected behavior of MU?

We defined the rules for updates in an intentional way to ensure that users who are using LTS versions stay on LTS versions. This means that you might not be updated to the latest version of PowerShell 7 when you expected.

These are the rules for updates:

  • If you are running 7.4 (LTS), you will receive updates to 7.4 (LTS)
  • If you are running 7.5 (stable), you will receive updates to 7.5 (stable)
  • If you are running any preview or release candidate (rc) version, you will receive updates to next latest preview version as they come out.

We will never update an LTS version to a stable non-LTS version, like 7.4 to 7.5. However, a stable non-LTS release WILL be upgraded to the higher LTS release when support for the stable release ends. The only time we update an LTS version to a different version would be when an LTS version is out of support. For example, we will update 7.4 to 7.6 (next LTS) once 7.4 goes out of support.

Preview versions will never be updated to the latest stable version. Instead, we will update you to the latest preview release. This means if you are on 7.5-rc.1 you will be updated to 7.6-preview.2 (since preview.1 was skipped) instead of 7.5.

NOTE

Beginning March 14, 2025, we will be updating users who are on 7.2 to 7.4.

Helpful Links

Hopefully this post helps you understand the MU process. If you want more information about our MU release process, PowerShell releases, or the PowerShell Support Lifecycle, check out the following articles.

Feedback

As always, we look forward to your feedback. You can provide feedback via GitHub Issues.

Thank you so much!

Steven Bucher

PM on the PowerShell Team

The post Microsoft Update changes for PowerShell 7 appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/microsoft-update-changes-for-powershell-7/feed/ 3
Announcing the Public Preview of AI Shell https://devblogs.microsoft.com/powershell/announcing-the-public-preview-of-ai-shell/ https://devblogs.microsoft.com/powershell/announcing-the-public-preview-of-ai-shell/#comments Tue, 19 Nov 2024 20:28:06 +0000 https://devblogs.microsoft.com/powershell/?p=20632 We are pleased to announce the public preview of AI Shell.

The post Announcing the Public Preview of AI Shell appeared first on PowerShell Team.

]]>

We’re thrilled to unveil the public preview of AI Shell! AI Shell enhances your shell with AI capabilities to facilitate your interactions with the command line. AI Shell create an interactive shell that can interact with various large language model and provides a framework that you can use to build a custom system that meet your needs. Users can interact with the AI agents in a conversational manner.

The AI Shell project includes:

  • The command-line shell (aish) interface
  • A framework for creating AI agents and other assistance providers
  • A PowerShell module for deeper integration with PowerShell.
  • Built in AI agents to get you started assistance immediately

Each AI assistant is known as an agent. The initial release of AI Shell includes two agents:

  1. Azure OpenAI Agent: Powering general-purpose assistance, the Azure OpenAI agent can use any of the AI models provided by Azure open AI to handle broad queries, natural language interpretations or code generation. You can connect it to your deployed Azure OpenAI models if you are looking for more privacy, management of the model settings, or have a model trained with your data. Additionally, you can also utilize OpenAI’s models.
  2. Copilot in Azure: This agent brings the power of Copilot in Azure directly to your CLI. It specializes in delivering cloud-centric assistance, providing Azure CLI and Azure PowerShell commands and helping you automate your Azure-specific tasks.To get started with the Copilot in Azure agent you need sign in to Azure with Azure CLI with an account that has the IAM role for accessing Copilot in Azure.

NOTE

The Azure OpenAI agent needs additional configuration to connect to your Azure OpenAI instance. To get started, follow the instructions provided when you start start the agent.

Recognizing that you may have different CLI command needs, AI Shell provides a framework for creating your own agents. For more information, see Creating an Agent.

Using and Installing AI Shell

We know every CLI user has their own preferences, so AI Shell offers two flexible modes to fit your workflow:

Standalone Executable

You can use AI Shell as a self-contained executable, allowing it to run independently from any shell. This setup is perfect if you’re looking for a dedicated, streamlined experience that’s easily accessible without dependencies.

A GIF of the standalone experience

Side-by-Side Integration with PowerShell 7

This is the recommended method for using AI Shell because it enables an uninterrupted work flow. The AIShell module connects the aish tool to your PowerShell 7 session for deeply integrated user experience. AI Shell opens in a side pane right next to your PowerShell 7 session that enables a rich communication between panes, results from the chat can be carried seamlessly to your PowerShell session for easy execution and the AI agent can be used to provide assistance to resolve a PowerShell error.

A GIF of the side-by-side experience

Installation and Getting Started

Some system requirements are needed to run AI Shell.

AI Shell (aish) and the AIShell module are separate downloads. For your convenience, we created a script to download and install them for you.

Windows

Some prerequisites are needed to run AI Shell on Windows.

  • Windows 10 or higher
  • PowerShell 7.4.6 or higher
  • Windows Terminal

The following install script will:

  • Installs aish.exe to $env:LOCALAPPDATA\Programs\AIShell and adds it to your PATH
  • Installs the AIShell module to your module path location
MacOS

Some prerequisites are needed to run AI Shell on MacOS.

  • macOS v13 Ventura or higher
  • PowerShell 7.4.6 or higher
  • iTerm2 terminal app

On MacOS, this script:

  • Installs the aish executable to /usr/local/AIShell and creates a symbolic link at /usr/local/bin/aish
  • Due to some limitations, the AIShell module is not installed

NOTE

This script only works on Windows and Mac systems. Linux users need to follow the manual installation instructions.

To install AI Shell, run the following command in your PowerShell session:

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }"

To find details on manual installation please see, Installing AI Shell manually.

After running the install script, you can run Start-AIShell to begin using AI Shell.

A GIF of the start up experience

AI Shell starts in the side by side experience. You can switch between the agents by using the @<agent name> command. For example, to switch to the Azure OpenAI agent you would use the @openai-gpt command. Additionally you can do @<agent name> <question> to send a question to the agent immediately.

A GIF of the agent selection experience

Inserting code into the PowerShell 7 session

Copying and pasting a lot of code can be annoying. AI Shell makes it easy to insert the AI generated code directly into your PowerShell 7 session with the /code post command. In your AI Shell, run /code post or use the Ctrl+d,Ctrl+d keyboard shortcut to copy the code into your PowerShell session.

A GIF of the code insertion experience

If you are familiar with PowerShell 7 you may be familiar with Predictive Intellisense. When you get multi-step commands in your AI Shell response, you can easily get each subsequent step in your Predictive Intellisense buffer.

A GIF of the code insertion experience with predictive Intellisense

Resolving errors quicker

If you encounter an error in your working terminal, you can use the Resolve-Error cmdlet to send that error to the open AI Shell window for resolution. This command asks the AI model to help you resolve the error.

A GIF of the error resolution experience

Invoking AIShell from PowerShell 7

One key scenario we wanted to support is being able to pipe output of one command into the AI Shell to get more information or ask a follow up question on the data given. With the Invoke-AIShell command you can easily do this.

A GIF of the Invoke-AIShell experience

Invoke-AIShell can take input from the pipeline but also can just be used to call the AI agent selected in AI Shell without having to switch back and forth.

Some additional tips using AI Shell

There are other chat commands and hot-keys that make using AI Shell easier. For a full list of the chat commands, see the AI Shell reference.

Key bindings Command Functionality
Ctrl+d, Ctrl+c /code copy Copy all the generated code snippets to clipboard
Ctrl+<n> /code copy <n> Copy the n-th generated code snippet to clipboard
Ctrl+d, Ctrl+d /code post Post all the generated code snippets to the connected application
Ctrl+d,<n> /code post <n> Post the n-th generated code snippet to the connected application

Additionally, you can switch between the panes easier using the following keyboard shortcuts.

Key bindings Functionality
Alt+RightArrow Moves your cursor to the right AI Shell pane
Alt+LeftArrow Moves your cursor to the left PowerShell pane

Why Try AI Shell?

AI Shell was built for those who seek intelligence and adaptability from their command-line. With multi-agent support, AI Shell aims to be the assistant for any CLI tool. You’ll benefit from advanced AI capabilities, deeper integration with your PowerShell session, and an extensibility model to get the assistance you need.

Call to Action!

This public preview is just the beginning. We’d love to hear your feedback and insights as we refine AI Shell to better serve the CLI and PowerShell community. Download it today in PowerShell with

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }"

Be sure to explore the capabilities of the Copilot in Azure and Azure OpenAI agents, and take command-line productivity to the next level! Feel free to give us feedback on the current tool and sign up for early access to future features at aka.ms/AIShell-Feedback.

Thank you so much!

Steven Bucher

Product Manager on the PowerShell/CLI Team

The post Announcing the Public Preview of AI Shell appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/announcing-the-public-preview-of-ai-shell/feed/ 6
PSReadLine 2.3.4 GA Release https://devblogs.microsoft.com/powershell/psreadline-2-3-4-ga-release/ Tue, 03 Oct 2023 18:21:11 +0000 https://devblogs.microsoft.com/powershell/?p=20138 We are excited to announce the general availability of PSReadLine 2.3.4!

The post PSReadLine 2.3.4 GA Release appeared first on PowerShell Team.

]]>

We are excited to announce the general availability of PSReadLine 2.3.4! After three preview releases we are ready to release the GA version of PSReadLine 2.3.4. There are no new features in this release from the previous preview but wanted to highlight some of the key changes since the previous stable version, 2.2.6.

Installing PSReadLine 2.3.4

As usual, here are the instructions for installing the latest PSReadLine module. PSReadLine is available from the PowerShell Gallery.

Use the following command to install PSReadLine using PowerShellGet v2.x:

Install-Module -Name PSReadLine -Force

If you are using the new PSResourceGet, you can use the following command:

Install-PSResource -Name PSReadLine

You may you need ot use the Force parameter to install this version side by side with any previous preview releases installed.

Note

You must restart your PowerShell session to use the new version of PSReadLine.

Highlights

Improvements to Predictors

We have improved the user experience for ListView for PowerShell Predictive IntelliSense. This includes allowing more than 10 responses, and adding a scrollable list view. To help with navigation, we have also included a metadata line that informs users of their position in the scroll.

Another addition are tooltips for plugin predictors. Tooltips are descriptions of prediction results to help provide more details about what is being predicted. For example, the Az.Tools.Predictor module provides details about what the suggested cmdlet does.

 

Image psrlga resized1

Additional Changes and fixes

Here are a few other changes and fixes that were made since the previous stable release:

  • Fix the menu completion to better handle the backspace key
  • Fix some typos in this repository (Thanks @spaette!)
  • Change default color for inline prediction to dim
  • Make tab completion show results whose ListItemText are different by case only (Thanks @dkaszews!)
  • Fix to use the default member color for members
  • Add support for upcasing, downcasing, and capitalizing word (Thanks @3N4N!)
  • Fix wrong cursor position in menu completion
  • Fix parameter dynamic help when the help content is specified in ParameterAttribute
  • Append reset VT sequence before rendering the inline prediction
  • Fix the broken doc link about PowerShellGet (Thanks @vimode!)
  • Add a sample for transforming Unicode code point to Unicode char by Alt+x
  • Improve the sensitive history scrubbing to allow retrieving token from az, gcloud, and kubectl
  • Improve the default sensitive history scrubbing to allow safe property access
  • Work around InvalidOperationException from Console API (Thanks @jazzdelightsme!)
  • Add the TerminateOrphanedConsoleApps option on Windows to kill orphaned console-attached process that may mess up reading from Console input (Thanks @jazzdelightsme)
  • Supports the text-object command diw in the VI edit mode (Thanks @springcomp!)

You can find the full list of changes on our PSReadLine release page, Big thank you to the community members who have helped contributed to this release! Thank you @spaette, @dkaszews, @vimode, @springcomp, @jazzdelightsme and @3N4N for your contributions!

Previous Blogs

Here are links to all the previous blogs for the PSReadLine releases that highlight the feature changes more closely.

Feedback

As per usual we love getting your feedback! Please submit bugs, feature requests, or questions to the repository. Your feedback is always welcomed and appreciated!

Thanks! Give the new version a try and let us know what you think!

Steven Bucher and Dongbo Wang

PSReadLine Maintainers

The post PSReadLine 2.3.4 GA Release appeared first on PowerShell Team.

]]>
PowerShell Adapter Feedback Provider https://devblogs.microsoft.com/powershell/powershell-adapter-feedback-provider/ Mon, 28 Aug 2023 22:42:15 +0000 https://devblogs.microsoft.com/powershell/?p=20099 This blog outlines the PowerShell Adapter Feedback Provider module

The post PowerShell Adapter Feedback Provider appeared first on PowerShell Team.

]]>
PowerShell Adapter Feedback Provider

We’ve renamed the JSON Adapter Feedback Provider to PowerShell Adapter Feedback Provider! We heard some good feedback that the name wasn’t as descriptive to what the feedback provider does so we’ve changed it to be more consistent with its functionality.

The Microsoft.PowerShell.PSAdapter is a module that identifies scripts and tools on the user machine that can help users more convert native command output into PowerShell objects. We designed this as a tool to help you discover what tools and scripts are available to help you convert native output to PowerShell objects.

Note

Feedback Providers are an experimental feature of 7.4-preview3+ and so you will be required to use one of the 7.4 previews for JSON Adapters to work and have `PSFeedbackProvider` experimental feature enabled .

Installing PowerShell Adapter Feedback Provider

The release is available from the PowerShell Gallery.

Use the following command to install using PowerShellGet v2.x:

Install-Module -Name Microsoft.PowerShell.PSAdapter -AllowPrerelease

If you are using PSResourceGet, you can use the following command:

Install-PSResource -Name Microsoft.PowerShell.PSAdapter -AllowPrerelease

To use it you must import the module into your session:

Import-Module Microsoft.PowerShell.PSAdapter

We encourage you to include this command in your $PROFILE so that it’s loaded in every PowerShell session you start.

What are PowerShell Adapters?

A PowerShell Adapter is a script that converts the text output of a native executable and converts it to PowerShell objects. The PowerShell Adapter module is a feedback provider that identifies these scripts and provides suggestions when you run the native command without any adapter script. You can read more about feedback providers in our blog post, What are feedback providers?.

You can make PowerShell Adapters for any command. Just use the exact name of the command as the prefix to the script so that the module can identify the script and suggest it. For example, you must name the script <name of command>-adapter.ps1 so that the PowerShell Adapter can identify it as a adapter script. This script’s file location must included in your $env:PATH variable to be found.

Creating an Adapter

For example, you want to use the macOS command vm_stat like a PowerShell object. Create a file called vm_stat-adapter.ps1 and add the location of this file to your $env:PATH variable. The PowerShell Adapter Feedback Provider will identify it as a possible suggestion for vm_stat.

Here is an example PowerShell Adapter for vm_stat:

[CmdletBinding()]
param ( [Parameter(ValueFromPipeline=$true)][string]$inputObject )
BEGIN {
    $h = @{}
}

PROCESS {
    if ( $inputObject -match "^Mach Virtual") {
        if ($inputObject -match "page size of (\d+) ") {
            $h['PageSize'] = [int]$matches[1]
        }
    }
    else {
        $k,$v = $inputObject -split ":"
        $AdjustedK = ($k -replace "[ -]","_").trim() -replace '"'
        $AdjustedV = "$v".Trim() -replace "\.$"
        $h[$AdjustedK] = [int64]$AdjustedV
    }
}

END {
    [pscustomobject]$h
}

The following shows the suggestion from the Feedback Provider when you run vm_stat without the adapter script:

Screenshot showing vm_stat suggestions.

For another example, we can create a PowerShell Adapter for the df utility using the TextUtility PowerShell module. We just need to create a df-adapter.ps1 script and include the following:

$input | ConvertFrom-TextTable -ConvertPropertyValue

DF utility adapter

Support for jc

The JSON Converter, jc, is a command line utility that converts text output to JSON for variety of command line tools. The PowerShell Adapter module can suggest using jc as an adapter if the user has it installed. When you use a command supported by jc, the PowerShell Adapter Feedback Provider suggests using jc piped to ConvertFrom-JSON.

You can find instructions on how to install jc and more details about the tool in their source code repository. When jc supports the native command, this can be the simplest way to convert the output without needing to write a PowerShell Adapter. You can see this suggestion in the previous screenshot for the df example.

The jc command supports many native commands, however, the Feedback Provider only provides jc suggestions for the following commands:
"arp", "cksum", "crontab", "date", "df", "dig", "dir", "du", "file", "finger",
"free", "hash", "id", "ifconfig", "iostat", "jobs", "lsof", "mount", "mpstat",
"netstat", "route", "stat", "sysctl", "traceroute", "uname", "uptime", "w", "wc",
"who", "zipinfo"

Also, you need to use the appropriate parameters with your native command for jc to work properly. For example, if you want to use jc with uname, you need to use uname -a because that produces the output that jc expect to convert to JSON.

Predictive IntelliSense Support

We’ve also added Predictive IntelliSense support for the PowerShell Adapter feedback provider. With Predictive IntelliSense enabled, the PowerShell Adapter Feedback Provider provides suggestions that Predictive IntelliSense will show you on the command line. This makes it easy to try immediately, rather than manually running the suggestion.

Screenshot showing predictive intellisense support

Feedback

We really appreciated the feedback we got on the first announcement of this tool and would love to continue getting great feedback! The GitHub repository for this tool is still named JSONAdapters, however the module name is Microsoft.PowerShell.PSAdapter and any reference to this tool will be PowerShell Adapters going forward. You can submit any feedback to the JsonAdapter repository.

Thank you so much!

Steven Bucher

PowerShell Team

The post PowerShell Adapter Feedback Provider appeared first on PowerShell Team.

]]>
JSON Adapter Feedback Provider https://devblogs.microsoft.com/powershell/json-adapter-feedback-provider/ https://devblogs.microsoft.com/powershell/json-adapter-feedback-provider/#comments Mon, 10 Jul 2023 21:00:44 +0000 https://devblogs.microsoft.com/powershell/?p=20040 This blog outlines a new feedback provider developed by the PowerShell Team to inform users of native executables that can output `JSON`.

The post JSON Adapter Feedback Provider appeared first on PowerShell Team.

]]>
JSON Adapter Feedback Provider Release

Caution

This blog post is outdated, please see the updated blog, PowerShell Adapter Feedback Provider Blog

 

We are excited to announce the first release of our JSON Adapter Feedback Provider! If you are unfamiliar with what feedback providers are, check out this blog describing them, here.

Note

Feedback Providers are an experimental feature of 7.4-preview2+ and so you will be required to use one of the 7.4 previews for JSON Adapters to work.

Installing JSON Adapter Feedback Provider

First to get the latest PowerShell preview for this to work on you can download them on our GitHub release page here.

The release is available from the PowerShell Gallery.

Use the following command to install JsonAdapter using PowerShellGet v2.x:

Install-Module -Name Microsoft.PowerShell.JsonAdapter -AllowPrerelease 

If you are using PSResourceGet, you can use the following command:

Install-PSResource -Name Microsoft.PowerShell.JsonAdapter -PreRelease

To use it you will need to import the module into your session via:

Import-Module Microsoft.PowerShell.JsonAdapter

We encourage you to include the import message in your $PROFILE so it can persistently be loaded in every PowerShell session you start. If you have Visual Studio Code installed, type code $PROFILE to edit your profile or use your choice of editor.

What are JSON Adapters?

A JSON adapter is a script that can parse the text output of a native executable and convert it to PowerShell Object. JSON adapters can be made for any command, it is just required to use the exact name of the command as the prefix to the script. The script will have to be named like so <name of command>-json.ps1 to be identified by the JSON adapter utility. This script’s file location must also be added to your $env:PATH variable to be found.

Creating a JSON Adapter

For example, say you are on a Mac and want to use the command vm_stat like a PowerShell object. If you add the following to a file called vm_stat-json.ps1 and add the location of this file to your $env:PATH variable, the JSON Adapter feedback provider will identify it as a possible suggestion for vm_stat.

[CmdletBinding()]
param ( [Parameter(ValueFromPipeline=$true)][string]$inputObject )
BEGIN {
    $h = @{}
}

PROCESS {
    if ( $inputObject -match "^Mach Virtual") {
        if ($inputObject -match "page size of (\d+) ") {
            $h['PageSize'] = [int]$matches[1]
        }
    }
    else {
        $k,$v = $inputObject -split ":"
        $AdjustedK = ($k -replace "[ -]","_").trim() -replace '"'
        $AdjustedV = "$v".Trim() -replace "\.$"
        $h[$AdjustedK] = [int64]$AdjustedV
    }
}

END {
    [pscustomobject]$h
}

 

This is what the experience looks like in the shell.

VM stat screenshot

JC

JC or JSON Converter, is a command line utility that can convert text to JSON for variety of command line tools. You can find instructions on how to install jc and a full list of supported commands on the repo of jc. It can be a great tool to use to convert the outputs without writing a JSON Adapter yourself. The JSON Adapter module supports using jc as a JSON Adapter if the user has it installed. This means if you have the jc utility installed and use a command that is supported by JC, the JSON Adapter feedback provider will suggest using JC piped to ConvertFrom-JSON.

It is important to note that not all jc supported utilities are supported. The list of supported commands is:

"arp", "cksum", "crontab", "date", "df", "dig", "dir", "du", "file", "finger",
"free", "hash", "id", "ifconfig", "iostat", "jobs", "lsof", "mount", "mpstat",
"netstat", "route", "stat", "sysctl", "traceroute", "uname", "uptime", "w", "wc",
"who", "zipinfo"

Additionally, you will need to use the appropriate parameters that jc requires to work properly. For example, if you want to use jc with uname, you will need to use uname -a as that is what jc requires to properly convert the output to JSON.

Predictive IntelliSense Support

We have also added predictive IntelliSense support for the JSON Adapter feedback provider. This means after a JSON Adapter feedback provider is triggered, as you type the command name again, Predictive Intellisense will suggest the feedback command to you. This is a great way to easily try the suggestion after a JSON Adapter feedback provider is triggered.

screenshot showing predictive intellisense support

Feedback

As this is our very first release, we know there may be issues that arise. We definitely look forward to your feedback and suggestions! You can provide feedback on the repo for this project here. Many things are subject to change as we are in early development of this. Give it a try!

Jim Truher and Steven Bucher

PowerShell Team

The post JSON Adapter Feedback Provider appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/json-adapter-feedback-provider/feed/ 5
What are Feedback Providers? https://devblogs.microsoft.com/powershell/what-are-feedback-providers/ https://devblogs.microsoft.com/powershell/what-are-feedback-providers/#comments Thu, 06 Jul 2023 19:24:36 +0000 https://devblogs.microsoft.com/powershell/?p=20018 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.

The post What are Feedback Providers? appeared first on PowerShell Team.

]]>
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

The post What are Feedback Providers? appeared first on PowerShell Team.

]]>
https://devblogs.microsoft.com/powershell/what-are-feedback-providers/feed/ 2
Completion Predictor v0.1.1 Release https://devblogs.microsoft.com/powershell/completion-predictor-version-0-1-1-release/ Wed, 10 May 2023 16:38:44 +0000 https://devblogs.microsoft.com/powershell/?p=19963 We released a new version of the CompletionPredictor! This blog post highlights some of the new functionalities of it.

The post Completion Predictor v0.1.1 Release appeared first on PowerShell Team.

]]>

We’ve recently released a new version of the Completion Predictor! We’ve been highlighting this predictor when showing off some of the new improvements in the PSReadLine 2.3.x betas and wanted to share some of the awesome things you can do with this predictor.

Completion Predictor v0.1.1

If you are unfamiliar with the Completion Predictor, this is a plugin in predictor that we released last year that provides tab completion to help give prediction results. This means it can work for helping fill out parameters of cmdlets and properties and methods of objects. The Version 0.1.1 release contains some experience improvements and some new completion capabilities.

Installing Completion Predictor v0.1.1

First and foremost, how can you get this predictor? The release is available from the PowerShell Gallery.

Use the following command to install CompletionPredictor using PowerShellGet v2.x:

Install-Module -Name CompletionPredictor

If you are using PowerShellGet v3, you can use the following command:

Install-PSResource -Name CompletionPredictor

Argument Completion Improvements

cd and dir

Using tab completion we’re able to give predictions on the next folders you may want to navigate to with cd or view the contents of with dir.

Screenshot showing cd and dir argument completion.

git

Another argument completion improvement was with git. These are improvements that we’ve found works best for our workflow but may help with your git workflow as well!

Merging branches

Completion Predictor is able to look at remote and local branches available to accelerate your flow when using git merge. Here is an example of it working.

Screenshot showing git merge prediction completion.

 

Checking out and deleting branches

Similarly, to the merge behavior, the completion predictor is now able to give predictions on what branch you may want to use when checking out or deleting branches. This only works with the subcommands git checkout and git branch -D. The predictor intentionally doesn’t include the current branch you are in when giving results.

Screenshot showing git branch -D prediction completion.

As I mentioned, we added these improvements to help with our specific git workflows. Typically, the rough flow we’ve is the following:

  • git fetch --all -p -> to get the latest changes in that repo
  • git merge -> sync the default branch
  • git branch -D -> delete the old working branches that were already removed from the remote side
  • git checkout -> checkout a new branch to work in
  • git push -> push the new branch to remote to then create a PR

This isn’t a blog post about how to best use git, so please refer to other online resources to learn git. This is just the workflow we like to use that helped us create the git improvements to the Completion Predictor.

Feedback

You can find the rest of the changes in this release in the changelog on the release page. We love getting feedback on these predictors we make! The entire source code for this predictor is available on GitHub and can be a great starting point for making your own predictor! Please feel free to open issues or PRs on the GitHub page for improvements that may work for you and others! Enjoy!

Steven Bucher and Dongbo Wang

Completion Predictor and PSReadLine Maintainers

The post Completion Predictor v0.1.1 Release appeared first on PowerShell Team.

]]>
PSReadLine 2.3.1-beta1 Release https://devblogs.microsoft.com/powershell/psreadline-2-3-1-beta1-release/ Mon, 08 May 2023 15:42:54 +0000 https://devblogs.microsoft.com/powershell/?p=19936 We are very excited to annouce the release of PSReadLine 2.3.1-beta1 is now available on the PowerShell Gallery! We have added a brand new tool tip feature to help give more descriptions to predictor results.

The post PSReadLine 2.3.1-beta1 Release appeared first on PowerShell Team.

]]>

We are pleased to announce another release of PSReadLine 2.3.1-beta1! We have had various bug fixes and minor improvements in this release, as well as a big new feature to ListView of Predictors! Let’s jump right in!

Installing PSReadLine 2.3.1-beta1

How do you install this release? The release is available from the PowerShell Gallery.

Use the following command to install PSReadLine using PowerShellGet v2.x:

Install-Module -Name PSReadLine -AllowPrerelease -Force

If you are using PowerShellGet v3, you can use the following command:

Install-PSResource -Name PSReadLine -Prerelease

You must include the Force parameter to install this version side by side with the default stable version.

Note

You must restart your PowerShell session to use the new version of PSReadLine.

ListView tool tip view

In this preview, we enabled a new tooltip view in the ListView mode of PSReadLine Predictors. Tooltips were part of the original design but were never presented to the user until this release. Tooltips are enabled by default, but you can disable them by running the following command:

Set-PSReadLineOption -ShowToolTips:$false

And then can re-enable by running:

Set-PSReadLineOption -ShowToolTips

The following screenshot shows the CompletionPredictor providing tooltips to show details about each parameter of Write-Host and GetChildItem.

Note

You will need the CompletionPredictor installed and imported to have the same experiences shown in this blog.

 

Gif showing the tool tip option.

Tooltips are only available for results from plugin predictors. Predictions from History don’t have tooltips. A plugin predictor can populate the tooltip with other descriptions to help provide more details into what is being predicted. For example, the Az.Tools.Predictor module provides details about what the suggested cmdlet does.

Screenshot showing Az predictor tool tip

It’s also helpful when working with .NET objects:

Screenshot showing the .NET object tool tip completion

For long tooltips, ListView shows up to four lines of the tooltip. You can get more information for the selected item by pressing the F4 key.

GIF showing the F4 capabilities to expand a tooltip

See our changelog for a complete list of bug fixes and changes.

Feedback

As usual, we love getting your feedback! Since this is a beta release, designs and features are subject to change. Please submit bugs, feature requests, or questions to the repository. Your feedback is greatly appreciated!

Steven Bucher and Dongbo Wang

PSReadLine Maintainers

The post PSReadLine 2.3.1-beta1 Release appeared first on PowerShell Team.

]]>