What is Microsoft Power Platform CLI?
Microsoft Power Platform CLI is a simple, one-stop developer CLI that empowers developers and ISVs to perform various operations in Microsoft Power Platform related to:
- Environment lifecycle
- Authentication
- Microsoft Dataverse environments
- Solution packages
- Power Pages
- Code components
- and more...
Provide feedback
Use github.com/microsoft/powerplatform-build-tools/discussions to view and submit feedback for PAC CLI.
Install Microsoft Power Platform CLI
There are three ways to install the Power Platform CLI. You can use multiple installation methods on the same computer.
Method | OS Support | Description |
---|---|---|
Install the Visual Studio Code extension | Windows, Linux, macOS | Enables use of commands within a PowerShell terminal within Visual Studio Code on Windows 10, Windows 11, Linux, and macOS. When you install using ONLY this method, by default PAC CLI will only be available within a Visual Studio Code terminal unless you enable PAC CLI in Command Prompt (CMD) and PowerShell terminals for Windows |
Install with .NET Tool | Windows, Linux, macOS | Enables use of commands within a PowerShell, CMD, or Bash shell on Windows 10, Windows 11, Linux, and macOS. This installation method doesn't enable use of pac data or certain pac package commands (deploy and show) that are only available for Windows. |
Install with Windows MSI | Windows only | Enables use of commands within a PowerShell terminal within Visual Studio Code on Windows only. You can manage installed versions with this installation method. |
Note
The following commands are only available on Windows:
To use these commands on Windows, install Power Platform CLI using either (or both) of these installation methods:
These commands aren't available on Windows if you only install using the .NET Tool.
Check whether Power Platform CLI is already installed
How to determine whether the Power Platform CLI is installed depends on your operating system.
Open a PowerShell terminal:
- If you ONLY installed the Visual Studio Code extension, open a Visual Studio Code Powershell terminal window.
- If you installed using the .NET Tool, open a Visual Studio Code Powershell terminal OR a Powershell terminal.
Type
Get-Command pac | Format-List
at the prompt, and press Enter.
The results should look something like this:
Name : pac.exe
CommandType : Application
Definition : C:\Users\you\.dotnet\tools\pac.exe
Extension : .exe
Path : C:\Users\you\.dotnet\tools\pac.exe
FileVersionInfo : File: C:\Users\you\.dotnet\tools\pac.exe
InternalName: pac.dll
OriginalFilename: pac.dll
FileVersion: 1.29.11
FileDescription: Microsoft Power Platform CLI
Product: Microsoft Power Platform©
ProductVersion: 1.29.11+g9e2b163
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: Language Neutral
When Power Platform CLI isn't installed, you'll get this error:
Get-Command: The term 'pac' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Check which version of Power Platform CLI is installed
Open the command prompt (on Microsoft Windows), or a Terminal session (in Linux), type pac
and press Enter.
You should see something like this where the version is on the second line.
Microsoft PowerPlatform CLI
Version: 1.30.3+g0f0e0b9
Manage auth profiles
Most PAC CLI commands require authenticated access to resources. You'll need to create and use auth profiles.
Note
With the Visual Studio Code extension, you can view and manage authentication profiles.
Connect to your tenant
Use the pac auth create command to connect to your tenant. Running pac auth create
creates an authentication profile on your machine. You can have multiple authentication profiles available. Having multiple authentication profiles is interesting when you work with multiple tenants. For instance, when your company uses multiple tenants (for development, production, and test) or when you're a consultant that works for multiple customers.
The pac auth create
command has a couple of helpful parameters:
The
--environment
parameter enables you to automatically connect to the right environment. If you omit the--environment
parameter, you're connected to the default environment, but with the--environment
parameter added to it, you can connect to a different one. You can use the environment ID, url, unique name, or partial name as the value.In environments where you don't have the ability to use an interactive experience, adding the
--deviceCode
parameter makes sure you can still connect. For example, in GitHub Codespaces, the--deviceCode
parameter automatically gets added when you runpac auth create
.
Example
To connect to the HR-Dev
environment, you can use the following example:
pac auth create --environment "HR-Dev"
Switch to another authentication profile
When you have multiple authentication profiles, you can easily switch using the pac auth list and pac auth select commands.
The pac auth list
command lists all authentication profiles on your machine. The pac auth select
command selects a different command.
pac auth list
Example
To list all authentication profiles, use the following example:
pac auth list
Running the pac auth list
command returns all authentication profiles:
Index Active Kind Name Friendly Name Url User Cloud Type
[1] * UNIVERSAL Personal Productivity (Default) https://x.crm.dynamics.com/ user@contoso.onmicrosoft.com Public User
Select a different authentication profile using the index value.
pac auth select --index 2
Enable tab completion in PowerShell
Power Platform CLI has a pac complete
command similar to the .NET CLI complete command.
When configured using the instructions below, you can type just the beginning of a command and then use the Tab key to complete the input entered.
To add tab completion to PowerShell for the PAC CLI, create or edit the profile stored in the variable $PROFILE
. For more information, see How to create your profile and Profiles and execution policy.
Add the following code to your profile:
$scriptblock = {
param($wordToComplete, $commandAst, $cursorPosition)
&pac complete -s "$($commandAst.ToString())" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Register-ArgumentCompleter -Native -CommandName pac -ScriptBlock $scriptblock
Other Shells
You can also use this with bash, zsh, fish, and nushell. Instead of dotnet complete
use pac complete
US Sovereign cloud availability
Microsoft Power Platform CLI is available for use in the GCC and GCC High (US Sovereign cloud) regions. See the --cloud
parameter for the pac auth create command to find out about supported US Sovereign cloud environments.
Next steps
Learn about the commands. For the complete list of supported commands, run the pac help
command or pac <subcommand> help
- for example: pac solution help
.
Or view the list of commands in the documentation:
See also
Microsoft Power Platform CLI release notes
Microsoft Power Platform CLI Command Groups
Power Apps component framework
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for