> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/cloud/microsoft-azure/microsoft-entra-powershell.md).

# Microsoft Entra PowerShell

The Microsoft Entra PowerShell module is a command-line tool that allows administrators to manage and automate Microsoft Entra resources programmatically. These capabilities include efficiently managing users, groups, applications, service principals, policies, and more. The module builds upon and is part of the Microsoft Graph PowerShell SDK. It’s fully interoperable with all cmdlets in the Microsoft Graph PowerShell SDK, enabling you to perform complex operations with simple, well-documented commands.

The module also offers a backward compatibility option to streamline migration from [the retiring AzureAD PowerShell module](https://techcommunity.microsoft.com/blog/identity/action-required-msonline-and-azuread-powershell-retirement---2025-info-and-resou/4364991). Microsoft Entra PowerShell works with Windows PowerShell 5.1 and PowerShell 7+. For the best experience on Windows, Linux, and macOS, we recommend using PowerShell 7 or later.

## Installation

[Install](https://learn.microsoft.com/en-us/powershell/entra-powershell/installation) the module from an elevated PowerShell

```powershell
Install-Module -Name Microsoft.Entra -Repository PSGallery -AllowClobber
```

## Import

Before using the module we need to import it

```powershell
Import-Module Microsoft.Entra
```

Please note that the module takes some time to import!

## Connect

Connect with [Connect-Entra](https://learn.microsoft.com/en-us/powershell/module/microsoft.entra.authentication/connect-entra?view=entra-powershell)

```powershell
Connect-Entra -Scopes User.Read.All
```

A Pop-up window will ask you for credentials.

## Enumeration

### List Domain Information

List domain information with [Get-EntraDomain](https://learn.microsoft.com/en-us/powershell/module/microsoft.entra.directorymanagement/get-entradomain?view=entra-powershell)

```powershell
Get-EntraDomain | Select-Object *
```

### List Groups

List users with [Get-EntraGroup](https://learn.microsoft.com/en-us/powershell/module/microsoft.entra.groups/get-entragroup?view=entra-powershell)

```powershell
Get-EntraGroup -All | Select-Object *
```

Search for flag in the output

```powershell
Get-EntraGroup -All | Select-Object * | findstr flag
```

### List Service Principles

List users with [Get-EntraServicePrincipal](https://learn.microsoft.com/en-us/powershell/module/microsoft.entra.applications/get-entraserviceprincipal?view=entra-powershell)

```powershell
Get-EntraServicePrincipal -All | Select-Object *
```

Search for flag in the output

```powershell
Get-EntraServicePrincipal -All | Select-Object * | findstr flag
```

### List Users

List users with [Get-EntraUser](https://learn.microsoft.com/en-us/powershell/module/microsoft.entra.users/get-entrauser?view=entra-powershell)

```powershell
Get-EntraUser -All | Select-Object *
```

Search for flag in the output

```powershell
Get-EntraUser -All | Select-Object * | findstr flag
```

## Resources

Microsoft Entra Cmdlet Reference - Microsoft Learn: <https://learn.microsoft.com/en-us/powershell/module/microsoft.entra/?view=entra-powershell>
