Uninstall-Graph
GitHub

Clean uninstall for Microsoft cloud PowerShell modules

Removes Microsoft Graph, Entra, Azure (Az), and legacy AzureRM modules completely — handling dependency chains, retries, and leftover directories that Uninstall-Module leaves behind.

View source

Quick reference

CommandWhat it removes
Uninstall-GraphMicrosoft.Graph.* modules
Uninstall-Graph -EntraMicrosoft.Entra.* modules only
Uninstall-Graph -AllMicrosoft.Graph.* + Microsoft.Entra.* modules
Uninstall-AzAz.* modules + legacy AzureRM.* modules
Uninstall-AllAll of the above + AIPService, MSIdentityTools, AzureAD, ExchangeOnlineManagement, MicrosoftTeams, and more

All commands support -SkipAdminCheck to run without elevated privileges on Windows.

Installation

From PowerShell Gallery
Install-Module Uninstall-Graph

Uninstall Microsoft Graph

Removes all Microsoft.Graph.* modules. Add -Entra for Entra modules, or -All for both.

Graph only (default)
Uninstall-Graph
Entra only
Uninstall-Graph -Entra
Graph + Entra
Uninstall-Graph -All
Without admin rights
Uninstall-Graph -SkipAdminCheck

Uninstall Azure PowerShell (Az)

Removes all Az.* modules and automatically cleans up legacy AzureRM.* modules if present.

All Az + AzureRM modules
Uninstall-Az
Without admin rights
Uninstall-Az -SkipAdminCheck

Uninstall everything

Removes all Microsoft cloud PowerShell modules in one go — Graph, Entra, Az, AzureRM, plus additional modules like ExchangeOnlineManagement, MicrosoftTeams, and AzureAD.

Remove all cloud modules
Uninstall-All
Without admin rights
Uninstall-All -SkipAdminCheck

Why not just use Uninstall-Module?

Microsoft Graph, Azure PowerShell (Az), and legacy AzureRM all ship with dozens of interdependent sub-modules. Running Uninstall-Module fails partway through because of dependency ordering, leaves module directories on disk, and often requires multiple manual passes.

This module handles the complexity by:

  • Retrying multiple times — dependency conflicts prevent removal on the first pass, so it loops up to 10 iterations until everything is gone.
  • Ordering by dependency — base modules like Az.Accounts and AzureRM.Profile are removed last.
  • Cleaning up leftover directories — even after Uninstall-Module, folders remain on disk. This script removes them.
  • Using Microsoft's recommended tools — for AzureRM, it tries Uninstall-AzureRm from Az.Accounts before falling back to manual cleanup.