Microsoft has recently unveiled the public preview of AI Shell, an innovative command-line utility that integrates generative AI capabilities directly into Windows PowerShell. This new tool bears a striking resemblance to the Terminal Chat feature introduced in the Windows 11 Canary Build last October. Both AI Shell and Terminal Chat aim to simplify command-line interactions, making it easier for users to understand and execute commands. The AI integration is designed to offer explanations, suggestions, and assistance in troubleshooting errors, enhancing the overall user experience.
Currently, AI Shell comes equipped with two AI agents: Azure OpenAI and Copilot in Azure. However, its flexible framework allows for the creation and integration of additional AI agents, enabling users to select the large language model (LLM) that best suits their specific requirements. The installation process for AI Shell is straightforward, requiring only Windows 10 or later and PowerShell version 7.4.6. Users can easily install AI Shell by executing the following script:
Invoke-Expression “& { $(Invoke-RestMethod ‘https://aka.ms/install-aishell.ps1’) }”
Hands on with AI Shell
After installation, configuring AI Shell is equally simple. For those utilizing OpenAI, the process involves adding API keys. To configure, users need to open PowerShell, execute the Start-AIShell command, and select their preferred agent. Following this, running the /agent config command opens the configuration file, where users can uncomment the relevant section and input their API keys. Once saved, the configuration is complete, and users can begin interacting with AI Shell.
In my experience, I started with basic inquiries such as, “What can you do?” which provided a foundational understanding of its features. When I asked for a list of files larger than 200 MB on my PC, AI Shell responded with a command:
Get-ChildItem -Path “C:PathToSearch” -Recurse -File | Where-Object { $_.Length -gt 200MB } | Select-Object FullName, Length
It prompted me to replace the path with my desired directory, and when I requested a scan of my entire PC, it updated the script accordingly. However, the initial execution returned directories with access denied errors, obscuring the file sizes. I then asked AI Shell to exclude these directories and display the file size first, followed by the file name and directory. It provided the following refined script:
Get-ChildItem -Path “C:” -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $.Length -gt 200MB } | Select-Object @{Name=”SizeMB”; Expression={[math]::Round($.Length / 1MB, 2)}}, FullName, DirectoryName
Executing this command yielded the desired results. I also inquired whether AI Shell could generate Python code, to which it affirmed. I requested a basic calculator script, and it delivered a functional Python script that performed as expected.
In our tests, Windows Latest noted that AI Shell can also provide explanations for cmdlets, assist in writing or refining PowerShell scripts, or serve as a general AI assistant. Beyond the features already mentioned, AI Shell offers several additional advantages for Windows 11 users:
- The /code post command allows users to post generated code from AI Shell directly to the PowerShell terminal.
- The /code copy command facilitates copying the generated code.
- The resolve-error command sends errors to AI Shell for resolution, mirroring the functionality of Windows Terminal Chat, which also utilizes ChatGPT.
- The Invoke-AIShell command enables users to send queries to AI Shell, with or without accompanying code.
AI Shell presents a promising tool for users seeking to enhance their command-line experience. As it currently stands in public preview, there is potential for new features and improvements in the future.