How to use Copilot to help you with PowerShell and CMD commands

Last update: 11/09/2025
Author Isaac
  • Copilot Generates Azure PowerShell/CLI cmdlets and scripts from natural language.
  • AI Shell integrates Copilot into the terminal with authentication, /replace and optional telemetry.
  • PowerShellAI allows you to request and execute commands locally with GPT‑4 (key and cost).
  • En Windows, there are app controls, AppLocker and Copilot key for enterprise environments.

Copilot for PowerShell and CMD commands

Start asking the IA that generates exact commands for you PowerShell o CMD It's no longer science fiction: Copilot on Azure and other integrations They're here to speed up tasks, explain syntax, and automate routines with a simple, natural-language phrase. If you've ever thought, "What was that cmdlet parameter?" or "What CLI command do I need here?" you'll be interested in what follows.

The key is to combine the right pieces: Copilot in Azure within AI Shell to help you from the command line itself, generating Azure PowerShell and Azure CLI scripts and cmdlets, and using the PowerShellAI module (integrated with GPT‑4) when you want to bring that flow to your local PowerShell. In addition, we will see new features and controls for Copilot on Windows/Microsoft 365 that affect the experience in managed environments, along with sensitive points such as telemetry, policies and the famous key hardware.

What Copilot does in Azure with PowerShell and CMD

When you tell Copilot in Azure a task, the wizard generates the task. script PowerShell with the appropriate cmdlets and clearly indicates which placeholder values ​​you should replace with those from your environment. This greatly simplifies setting up resources in Azure and daily management.

The best thing is that you can use requests in natural languageSome will return a single cmdlet, while others will offer a complete sequence of steps. If you need a straightforward "cookbook," this will do; if you're looking for a script with multiple operations, Copilot also handles that pattern without breaking a sweat.

To give you an idea, here you have typical indications that Copilot understands and transforms into concrete commands:

  • “How do I list my virtual machines in Azure using PowerShell?”
  • “Create an account storage with PowerShell”
  • “Get subscription quota limits with Azure PowerShell”
  • “Stop all virtual machines in a specific resource group using PowerShell”

For simple queries, Copilot can respond with a single cmdlet, such as when you ask “How do I list all my resource groups using PowerShell?”. In others, it will suggest a complete script, for example: “Please help me write an Azure PowerShell script that runs directly and after creating a virtual machine, deploys an AKS cluster.”. You can copy and adapt that block, since Copilot marks the values ​​to replace.

Generating commands with Copilot

AI Shell: Copilot on Azure directly from your terminal

AI Shell is an interactive interpreter that gives you a chat interface in the CLI to speak with agents connected to Copilot in Azure and other models. From there, you ask for "what you want to achieve" and receive the appropriate Azure CLI or Azure PowerShell command or script. The benefits? Guided learning, troubleshooting common errors, and more agile workflows.

Before starting, check the Prerequisites from the Copilot agent on Azure for AI Shell:

  • Windows 11 21H2 or later
  • Windows Terminal v1.19 or later
  • Azure CLI 2.30.0 or later installed
  • Azure PowerShell 14.0.0 or later installed
  • Valid token after logging in with az login o Connect-AzAccount

Please note that the agent supports authentication so much with az login (CLI) as with Connect-AzAccount (PowerShell). It is good practice to log in before to open AI Shell, so the token cache already contains a valid access and you don't waste time.

An interesting plus is the command /replace When working with Azure PowerShell, the agent guides you through a safe and orderly replacement parameter values in generated responses. Avoid silly mistakes when adapting examples to your subscription or resources.

  The way to Repair Utility Was Unable to Begin Appropriately 0xc0000005

If you are wondering what kind of consultations fit well, you can ask questions like:

  • “How do I create a new resource group using the Azure CLI?”
  • “How to list storage accounts in Azure PowerShell?”
  • “What is Application Insights?”
  • “How to create a web application with the Azure CLI?”

AI Shell also incorporates a couple of details of product experience Very practical. On the one hand, telemetry is minimal and can be disabled; on the other, you can adjust the agent's settings with a simple command within the environment itself.

The Copilot agent in Azure collects only some usage data to improve quality: commands with bar you run, number of questions, type of operating system, exceptions and details you send with /like o /dislike. No personal data. If you want, you can view and edit your settings with /agent config, which opens a JSON with keys like:

{ "logging": true, "telemetry": true }

When you enable logging, the agent writes in ~/.aish/agent-config/azure. If you don't want to leave a trace, disable it by putting "logging": false. And, similarly, telemetry is disabled by adjusting "telemetry": false. Everything very clear and reversible.

PowerShellAI: GPT‑4-style Copilot in your local PowerShell

Another approach that has become popular is to use the module PowerShellAI, which integrates a Copilot-like assistant directly into the PowerShell console to translate natural language instructions to commandsIf you don't remember the exact grammar, just type what you want and the AI ​​will suggest the command ready to execute.

First install and import the module:

Install-Module PowerShellAI

Import-Module PowerShellAI

To link it to your account OpenAI (GPT‑4 model via API), you need a secret keyYou generate it on the OpenAI website and upload it like this:

Set-OpenAIKey

Be careful with this: the use of GPT‑4 via API is of payment for useIf you don't have any funds left, you'll see errors like "You exceeded your current quota...". It's a good idea to check the chosen model and the cost per token to avoid any surprises.

With everything ready, you start the assistant mode with:

Copilot

From there, ask questions in English or Spanish (preferably contextualized) and decide what to do with the suggestion: run it as is, copy it, ask for an explanation, or leave without changes. For example, when asked to "List all items in the folder," the AI ​​might return:

Get-ChildItem -Force

And if you ask “delete temp.txt”, you will see something like:

Remove-Item "temp.txt"

Its effectiveness is high, but not infallible. Sometimes it can suggest obsolete or non-ideal commandsSo, especially if you have elevated privileges on a domain or tenant, remember: review before launching anything that could impact production.

Prompts and Scenarios: From Single Cmdlets to Complete Scripts

For specific tasks, Copilot can deliver you an exact cmdletClassic examples: listing resource groups, creating a resource group, or checking subscription quotas. Requests like “I want the quota limits” or “show me how to list my resource groups” are resolved with the correct syntax and with well-placed parameters.

When you're looking for a multi-phased solution, Copilot can generate a multi-cmdlet script and clarify which placeholders you should replace. Think of it as a complete recipe: create a VM and then deploy an AKS cluster. In that block, you'll see resource names, locations, and sizes highlighted so you can adapt them to your needs.

For example, if your goal is “stop all virtual machines in a resource pool”, Copilot will suggest the approach with loops or high-level commands that encompass the entire set, with the resource group as a variable.

  How to migrate a database from MS Access to SQL Server step by step

Similarly, “create a storage account” is resolved with the appropriate cmdlet (or CLI command if you request it), with recommended properties and options, and reminders for labels, redundancy, or encryption based on your policies.

Guided learning and resources

If you are just starting out or want to Copilot mentors you, accompany your prompts with context: what subscription you use, what region you work in, whether you prefer Azure CLI or PowerShell, and your ultimate goal. The more you describe your goal, the more straightforward the suggested command will be and the fewer adjustments you'll need to make later.

Microsoft offers Copilot training pieces for developers, including chapters that review how to provide context, pair program with PowerShell, and use the GitHub Copilot CLIA typical structure includes:

  • 00:00 – Introduction
  • 00:55 – Provide context
  • 02:17 – Double with PowerShell
  • 04:36 – GitHub Copilot CLI
  • 05:38 – Summary

At AI Shell, you also have commands to send feedback directly on your terminal (/like y /dislike) on Copilot's responses. This feedback loop helps future suggestions better fit your use cases.

Copilot on Windows and Microsoft 365 Copilot Chat: Changes for Businesses

Since September 2024, Microsoft has adjusted the Copilot experience on Windows for users who sign in with Microsoft work or school accounts Sign in, strengthening security, privacy and compliance. Microsoft 365 Copilot Chat is offered at no additional cost and redirects to a simpler interface, with promises of Enterprise Data Protection (EDP) that apply to queries and responses.

On new devices with Entra accounts, the Microsoft 365 Copilot app It is usually pinned to the taskbar. Those with a Microsoft 365 Copilot license will also see Copilot Chat anchored within the app, and they’ll be able to toggle between “web” and “work” to root conversations in organizational data when appropriate.

Administrators can decide whether to anchor or not Copilot Chat by default. If you don't pin it but allow prompting, the system will suggest pinning it to Microsoft 365 Copilot, Outlook, or Teams. If you prohibit both, Copilot Chat won't appear in those settings. apps (although it will still be accessible via the web unless the IT team blocks the URL).

A note: the application Consumer Copilot does not support authentication. Sign in. If a user attempts to sign in with that account, they're redirected to the browser with the work-appropriate experience. In managed environments, the recommended entry point is the Microsoft 365 Copilot app, preferably pinned to their navigation bar.

Installing, blocking, and uninstalling the Copilot app (Windows)

In enterprise deployments, you may want to avoid the consumer app or remove it from your devices. As a user, you can uninstall it From Settings > Apps > Installed Apps, tap the three dots, and select “Uninstall.” Simple and straightforward.

If you are an IT administrator and want to prevent its installation, you can use AppLocker Before Windows updates. The policy specifies the publisher and package of the Copilot app to block its deployment or its execution if it's already installed:

  • Publisher: CN=MICROSOFT CORPORATION, O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US
  • Package name: MICROSOFT.COPILOT
  • Package version: * (and later)

Additionally, you can audit or remove the app with PowerShell by running something like:

# Obtener el nombre completo del paquete de Copilot
$packageFullName = Get-AppxPackage -Name "Microsoft.Copilot" | Select-Object -ExpandProperty PackageFullName
# Quitar la aplicación Copilot
Remove-AppxPackage -Package $packageFullName

This approach gives you fine control: you block before that the update is installed, or you withdraw later with scripting if already present. In strict enforcement environments, AppLocker is the recommended route over legacy policies.

  Filters, Boolean Operators, and Search Ranges in Windows: A Complete Guide

Copilot Hardware Key: Experience and Management

If you are a developer and you want your app to be able to remap the key, you must register as a hardware key provider for Microsoft Copilot, adding com.microsoft.windows.copilotkeyprovider as a name in uap3:AppExtension of the MSIX manifest. It is a requirement to appear in the selector and comply safety standards.

Administrators have at their disposal policies to control the key's destination app. At the CSP level, you can use ./User/Vendor/MSFT/Policy/Config/WindowsAI/SetCopilotHardwareKey, and via GPO the path “User Configuration > Administrative Templates > Windows Components > Copilot > Set Copilot hardware key”.

If you prefer to leave it up to the end user, there is a direct protocol to Configuration to open the key customization section: ms-settings:personalization-textinput-copilot-hardwarekeyThere you can choose "Search," "Custom," or the currently assigned app. To select Microsoft 365 Copilot, choose "Custom." If it doesn't appear, reinstall the app from the Microsoft Store.

CMD and Azure CLI: The Other Side of the Coin

While PowerShell is the star, Copilot on Azure also shines with Azure CLI. If you prefer that style, say so in your prompt (“in CLI, not PowerShell”) and it will give you what you need. Pure CMD, the utility is more indirect, because much of Azure administration goes through PowerShell or CLI, but Copilot can still suggest batch scripts or calls to az that you run from cmd.exe.

A typical example in Azure CLI would be: “Configure a virtual network in West US with three subnets”. Copilot suggests the command set de az network in the correct order, with names highlighted for you to customize. If your team is just starting out, it's a great way to learn syntax without having to read half the manual.

Telemetry, privacy and notices

As we saw, the Copilot agent for AI Shell picks up a minimal and anonymous telemetry that you can disable. It's useful for improving the product, but if your organization requires zero logging, put "telemetry": false and that's it. The activity log is configurable with "logging": false and points by default to ~/.aish/agent-config/azure.

On the web, certain platforms such as Reddit displays cookie notices and similar technologies for ad personalization and measurement. This won't affect you at the command level, but it's good to know when browsing technical threads: if you reject non-essential cookies, the platform may still use some to ensure basic functionality.

Finally, remember that Copilot is not omniscient: validates the commands, check sensitive parameters, and test in development environments before implementing them in production. You set the criteria; AI eliminates friction and syntax uncertainty.

The combination of Copilot on Azure (best if you use it via AI Shell in your terminal), the PowerShellAI module for local jobs and the Microsoft 365 Copilot controls on Windows allows you to cover everything from generating point cmdlets to complex, multi-step scripts, with tailored privacy policies and settings. It's a powerful balance between productivity and control that, when used well, speeds up your daily work without sacrificing best practices.

Using GitHub Copilot on the command line-8
Related article:
A complete guide to getting the most out of GitHub Copilot on the command line