Skip to main content

How to Delete a Power Platform CLI Profile with pac auth delete

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Every pac auth create leaves a profile on your computer, and it stays there until you remove it. pac auth delete removes one profile and keeps the rest. This guide deletes one by its name and checks what's left.

A Power Platform CLI authentication profile is a saved sign-in: an account, and often an environment that commands work with (How to Sign In to the Power Platform CLI with pac auth create). Profiles pile up: one per tenant, one per environment, one for a test. Deleting the ones you no longer use keeps pac auth list short, and stops a stale profile, for an environment that's gone, from being picked by mistake.

Syntax​

Microsoft's pac auth reference gives the command two ways to say which profile to delete:

Terminal
pac auth delete --name <profile-name>
pac auth delete --index <profile-index>
PartWhat it is
pac auth deleteThe command. The CLI's help describes it as "Delete a particular authentication profile".
--name <profile-name>The profile's name, as pac auth list shows it in the Name column: 1 to 30 characters. Short form -n.
--index <profile-index>The profile's number in the Index column of pac auth list, a whole number from 1. Short form -i.

The reference lists both options as optional. Name the profile with one of them.

Microsoft's reference, and the CLI's own help, describe --name as "The name of the profile to be active". That's the description of pac auth select's option of the same name. With pac auth delete, --name names the profile to delete, as the example below shows.

Name or Index?​

Use the name when the profile has one. Indexes move: when I deleted profile [1] from a list of two on this computer, the profile that had been [2] was [1] afterwards. A name stays the same until you rename it, so a command with --name can't hit the wrong profile after a delete.

A profile created without --name has an empty Name column. For that one, use --index, straight after pac auth list.

The Example​

The example deletes ExampleProfile, a profile made for this guide with pac auth create --name ExampleProfile --deviceCode. It sits beside another profile, OvertimeDemo, which stays.

Step 1: List the Profiles​

Terminal
pac auth list

pac auth list shows every profile on the computer, with * in the Active column for the one commands use:

A Terminal window: pac auth list with two profiles, [1] OvertimeDemo with the environment Overtime Timesheet Demo, and [2] ExampleProfile, marked active with an asterisk, with no environment

Output
Index Active Kind Name User Cloud Type Environment Environment Url ERP URL
[1] UNIVERSAL OvertimeDemo admin@example.com Public User Overtime Timesheet Demo https://org00000000.crm11.dynamics.com/
[2] * UNIVERSAL ExampleProfile admin@example.com Public User

ExampleProfile is [2], and it's the active profile. It has no environment, because it was created without --environment.

Step 2: Delete the Profile by Name​

Terminal
pac auth delete --name ExampleProfile

The CLI deletes it straight away, without asking, and prints what it deleted:

A Terminal window: pac auth delete --name ExampleProfile, then Deleted profile: UNIVERSAL ExampleProfile, admin@example.com, Public

Output
Deleted profile:
UNIVERSAL ExampleProfile : admin@example.com Public

There's no undo. Check the name before you press Enter.

Step 3: Check What's Left​

Terminal
pac auth list

A Terminal window: pac auth list with one profile left, [1] OvertimeDemo, now marked active with an asterisk

Output
Index Active Kind Name User Cloud Type Environment Environment Url ERP URL
[1] * UNIVERSAL OvertimeDemo admin@example.com Public User Overtime Timesheet Demo https://org00000000.crm11.dynamics.com/

ExampleProfile is gone. I had deleted the active profile, and the one left, OvertimeDemo, was now marked active. With more than one profile left, check the * before your next command, and choose another with pac auth select if it isn't the one you want.

Common Mistakes​

MistakeWhat happensDo this instead
Reusing an index from an older pac auth listIndexes move after a delete, so it can point at another profileUse --name, or list again first
Running pac auth clear to remove one profileThe help says it clears all authentication profiles stored on this computerpac auth delete for one profile
Adding --help to see the optionsError: An unknown argument --help was passed.pac auth delete help (the fix)
Expecting the next command to use the old profileAnother profile is active nowCheck the * in pac auth list

Troubleshooting​

SymptomLikely causeFix
The profile is still listedThe name or index didn't match itCopy the name from pac auth list and run the command again
Your next command works with another account or environmentThe profile you deleted was the active onepac auth select --name <name>
No profiles were found on this computer.You deleted the last onepac auth create when you need the CLI again

FAQ​

Does deleting a profile sign me out of Microsoft 365?​

No. It deletes a profile the CLI saved on your computer: the CLI's help describes pac auth list as listing the authentication profiles stored on this computer. Your account itself isn't deleted or changed.

Does it delete the environment the profile points at?​

No. The profile only points at an environment. Deleting the profile leaves the environment alone, and deleting an environment leaves its profiles on your computer (How to Delete an Environment in the Power Platform Admin Center).

How do I delete every profile at once?​

The CLI's help lists pac auth clear, which clears all authentication profiles stored on this computer. I deleted my profiles one at a time, with pac auth delete, and didn't run it.

What does pac auth list show when no profiles are left?​

When I later deleted the last profile on this computer, it said:

Output
No profiles were found on this computer. Please run 'pac auth create' to create one.

Conclusion​

pac auth list to see the profiles, pac auth delete --name <profile-name> to delete one, and pac auth list again to check what's left and which profile is active now. Prefer the name to the index, because indexes move after a delete.

Additional Resources​