Microsoft recently announced the public preview of AI Shell, a command-line utility that brings generative AI capabilities directly to Windows PowerShell. Interestingly, AI Shell shares many similarities with the Terminal Chat that Microsoft shipped in Windows 11 (Canary Build) in late October.
For example, the core concepts of both tools are quite the same. AI Shell and Terminal Chat are designed to make the command line interactions easier to understand and can help you write commands. The AI integration is also designed to provide explanations and suggestions while help you fix errors.
For the time being, AI Shell comes with only two AI agents, Azure OpenAI and Copilot in Azure, but its framework allows you to create and integrate other AI agents as well. It is a great thing as you can pick the LLM (large language model) that works best for your specific needs.
I installed the AI Shell on my PC, and I must say, the installation process was a breeze. All you need is Windows 10 or later and PowerShell 7.4.6 installed on your machine, and you’re good to go.
If you meet these requirements, you can run the following script to install AI Shell on your computer:
Invoke-Expression “& { $(Invoke-RestMethod ‘https://aka.ms/install-aishell.ps1’) }”
Hands on with AI Shell
Once installed, the next step is to configure it.
Configuration was also quite easy as I was using OpenAI, and it just required adding my API keys for configuration.
To do this, open PowerShell, run the Start-AIShell command and select your preferred agent.
Next, run the /agent config command in the AI Shell to open the configuration file. Here, you need to uncomment the following section and then add your API keys.
Next, save the file, and that’s it. You’ve successfully configured AI Shell.
Once everything is configured, you can start communicating with it.
I started asking very basic questions like “What you can do?” And it gave me a basic idea of its features.
Next, I asked, “I have a lot of files on my PC. I want to get a list of files that are above 200 MB in size along with the details about their specific locations.”
It gave me the following output:
Get-ChildItem -Path “C:PathToSearch” -Recurse -File | Where-Object { $_.Length -gt 200MB } | Select-Object FullName, Length
It prompted me to replace the path with the directory I wanted to scan. I told it, “I want to scan my entire PC for large files,” and it gave me an updated script with the C drive selected.
But when executed, the output included directories with access denied, and I couldn’t see the file size.
So, I asked it to exclude directories with denied access and show the file size in the first column, followed by the file name and directory. For this, it gave me the following script, and when I executed it in the PowerShell, I received the desired results.
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
Next, I asked AI Shell if it could generate Python code. It prompted yes, so I asked it to write Python code for a basic calculator, and it did. And the Python script also worked as expected.
In our tests, Windows Latest observed that you can also use it to get explanations of cmdlets, ask it to write or refine PowerShell scripts, or just as a regular AI assistant.
Now, let’s quickly talk about the best things about AI Shell for Windows 11 apart from the ones that I have already explained –
- The /code post command allows you to post generated code from the AI shell to the PowerShell terminal.
- The /code copy command helps you copy the code generated.
- The resolve-error command in the PowerShell terminal sends the error to the AI Shell windows to find a resolution. This is again very similar to Windows Terminal Chat, which also uses ChatGPT.
- The Invoke-AIShell command in the PowerShell terminal, along with the code or without the code, will help you send queries to the AI Shell.
So, that was my take on AI Shell. Overall, it is a great tool, and considering it is just a public preview, we may see some new features in it.
What are your thoughts on this? Let us know in the comment section below.
The post Hands on: Microsoft is building an AI Shell for Windows 11 command line appeared first on Windows Latest