> For the complete documentation index, see [llms.txt](https://docs.hackjiji.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackjiji.org/active-directory-pentesting/aad.md).

# AAD

## AAD Enumeration with powershell

```powerquery
install-module AzureAD
Connect-AzureAD
Get-AzureADUser -All $true
Get-AzureADUser 
Get-AzureADUser -All $true | Where-Object { $_.UserType -eq 'Member' } | Select-Object UserPrincipalName
```

`Get-AzureADUser` cmdlet with filtering and the `Select-Object` cmdlet to get the top 100 non-guest accounts. Here’s how:

```powershell
Get-AzureADUser -All $true | Where-Object { $_.UserType -eq 'Member' } | Select-Object -First 100
```

**Connect-AzureAD: Connects to Azure Active Directory**

```powershell
Connect-AzureAD
```

**Get-AzureADUser: Retrieves user information**

```powershell
Get-AzureADUser -All $true
```

**Get-AzureADGroup: Lists all groups in Azure AD**

```powershell
Get-AzureADGroup
```

**Get-AzureADGroupMember: Lists members of a specific group**

```powershell
Get-AzureADGroupMember -ObjectId "GROUP_ID"
```

**Get-AzureADDirectoryRole: Retrieves directory roles**

```powershell
Get-AzureADDirectoryRole
```

**Get-AzureADDirectoryRoleMember: Lists members of a directory role**

```powershell
Get-AzureADDirectoryRoleMember -ObjectId "ROLE_ID"
```

**Get-AzureADPolicy: Retrieves Azure AD policies**

```powershell
Get-AzureADPolicy
```

**Get-AzureADServicePrincipal: Lists service principals**

```powershell
Get-AzureADServicePrincipal
```

**Get-AzureADUserLicenseDetail: Retrieves license details for a user**

```powershell
Get-AzureADUserLicenseDetail -ObjectId "USER_ID"
```

**Get-AzureADUserMembership: Lists group memberships for a user**

```powershell
Get-AzureADUserMembership -ObjectId "USER_ID"
```

### Other Azure AD command's

| **Name**                                                                                                                                                                                       | **Description**                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [Get-AzureADDevice](https://azurelessons.com/get-azureaddevice/)                                                                                                                               | Can help you to retrieve the details of the lists of devices from your Azure AD.                                                   |
| [New-AzureADDevice](https://azurelessons.com/new-azureaddevice/)                                                                                                                               | Helps you to create a brand new device in your Azure Active Directory.                                                             |
| [Set-AzureADDevice](https://azurelessons.com/set-azureaddevice/)                                                                                                                               | Updates the details of your Azure AD device.                                                                                       |
| [Remove-AzureADDevice](https://azurelessons.com/remove-azureaddevice/)                                                                                                                         | Remove an Azure AD device.                                                                                                         |
| [Get-AzureADPolicy](https://azurelessons.com/get-azureadpolicy/)                                                                                                                               | Retrieve the details of your Azure AD Policy.                                                                                      |
| [New-AzureADPolicy](https://azurelessons.com/new-azureadpolicy/)                                                                                                                               | Create a brand new Azure AD Policy using this PowerShell command.                                                                  |
| [Set-AzureADPolicy](https://azurelessons.com/set-azureadpolicy/)                                                                                                                               | Update your Azure AD Policy.                                                                                                       |
| [Remove-AzureADPolicy](https://azurelessons.com/remove-azureadpolicy/)                                                                                                                         | Delete any unwanted Azure AD policy using this PowerShell command.                                                                 |
| [Get-AzureADDirectoryRole](https://azurelessons.com/get-azureaddirectoryrole/)                                                                                                                 | Retrieve the details of a directory role from your Azure Active Directory using this command.                                      |
| [Update-AzADUser](https://azurelessons.com/update-azaduser/)                                                                                                                                   | Update the entities in the Azure Active Directory users.                                                                           |
| [Get-AzureADObjectByObjectId](https://azurelessons.com/get-azureadobjectbyobjectid/)                                                                                                           | This command will retrieve the details of a directory role from your Azure Active Directory.                                       |
| [Disconnect-AzureAD](https://azurelessons.com/disconnect-azuread/)                                                                                                                             | Helps you to disconnect your current session from your Azure Active Directory tenant.                                              |
| [Connect-AzureAD](https://azurelessons.com/connect-azuread/)                                                                                                                                   | Helps you to use Azure AD cmdlet requests by connecting with an authenticated account.                                             |
| [Get-AzureADUserMembership](https://azurelessons.com/get-azureadusermembership/)                                                                                                               | Use this command to get the specified user membership in the Azure AD.                                                             |
| [Get-AzureADUser](https://azurelessons.com/get-azureaduser/)                                                                                                                                   | Helps you to get user details from your Azure Active Directory.                                                                    |
| [Get-AzADUser](https://azurelessons.com/get-azaduser/)                                                                                                                                         | Can get you the list of AD users.                                                                                                  |
| [Remove-AzADGroup](https://azurelessons.com/remove-azadgroup/)                                                                                                                                 | Use this command to remove the entity from the Azure AD groups.                                                                    |
| [Get-AzADApplication](https://azurelessons.com/get-azadapplication/)                                                                                                                           | Helps get the objects’ details based on the specified Object IDs.                                                                  |
| [New-AzADApplication](https://azurelessons.com/new-azadapplication/)                                                                                                                           | Use the New-AzADApplication PowerShell cmdlet to add the new entity to your applications.                                          |
| [Get-AzADGroup](https://azurelessons.com/get-azadgroup/)                                                                                                                                       | Use this command to get the lists of Azure Active Directory Groups.                                                                |
| [Get-AzSecuritySetting](https://azurelessons.com/get-azsecuritysetting/)                                                                                                                       | It will get you the security settings in the Azure Security Center.                                                                |
| [Get-AzTenant](https://azurelessons.com/get-aztenant/)                                                                                                                                         | Get the list of entities from the applications.                                                                                    |
| [New-AzTag](https://azurelessons.com/new-aztag/)                                                                                                                                               | It helps you quickly create a predefined Azure tag.                                                                                |
| [Get-AzTag](https://azurelessons.com/get-aztag/)                                                                                                                                               | Can help you to retrieve the lists of predefined Azure tags from your subscription.                                                |
| [Add-AzRouteConfig](https://azurelessons.com/add-azrouteconfig/)                                                                                                                               | Use this command to add a route to a specified Azure route table.                                                                  |
| [Get-AzRouteTable](https://azurelessons.com/get-azroutetable/)                                                                                                                                 | This can help you to retrieve the route tables under a Resource Group.                                                             |
| [Get-AzStorageContainer](https://azurelessons.com/get-azstoragecontainer/)                                                                                                                     | Helps you to retrieve the lists of Azure storage containers.                                                                       |
| [Remove-AzStorageContainer](https://azurelessons.com/remove-azstoragecontainer/)                                                                                                               | Helps you to remove the storage container that you have specified with this command.                                               |
| [New-AzStorageContext](https://azurelessons.com/new-azstoragecontext/)                                                                                                                         | Get the lists of storage queues associated with the specified storage account.                                                     |
| [Get-AzADServicePrincipal](https://azurelessons.com/get-azadserviceprincipal/)                                                                                                                 | Use this command to get the entities from the service principals.                                                                  |
| [New-AzADSpCredential](https://azurelessons.com/new-azadspcredential/#New-AzADSpCredential)                                                                                                    | It helps you to add a credential to an existing service principal.                                                                 |
| [Update-AzConfig](https://azurelessons.com/update-azconfig/)                                                                                                                                   | Update the configs of your Azure PowerShell using this command.                                                                    |
| [Uninstall-AzureRm](https://azurelessons.com/uninstall-azurerm/)                                                                                                                               | Helps you to uninstall or remove all the AzureRm modules from your machine                                                         |
| [Set-AzDefault](https://azurelessons.com/set-azdefault/)                                                                                                                                       | Helps you to create an Azure Storage context quickly.                                                                              |
| [Save-AzContext](https://azurelessons.com/save-azcontext/)                                                                                                                                     | Can help you to save the Az context of your current Azure session into a specified location or path.                               |
| [Get-AzEnvironment](https://azurelessons.com/get-azenvironment/)                                                                                                                               | Retrieve the endpoints and the metadata for the instance of the Azure services.                                                    |
| [Get-AzProvi](https://azurelessons.com/get-azproviderfeature/)[derFeature](https://azurelessons.com/get-azproviderfeature/)                                                                    | Use this command to add edit or set the default to your current Azure Context.                                                     |
| [Get-AzPolicyAssignment](https://azurelessons.com/get-azpolicyassignment/)                                                                                                                     | Retrieve the policy assignments.                                                                                                   |
| [Clear-AzDefault](https://azurelessons.com/clear-azdefault/)                                                                                                                                   | Helps to clear the current context default values set by the user.                                                                 |
| [Clear-AzConfig](https://azurelessons.com/clear-azconfig/)                                                                                                                                     | Helps you to retrieve the feature details like Feature name, Registration State, Provider name, etc. in a second.                  |
| [New-AzManagementGroup](https://azurelessons.com/new-azmanagementgroup/)                                                                                                                       | Clear all the configuration values set by the user using this command.                                                             |
| [Set-AzResourceGroup](https://azurelessons.com/set-azresourcegroup/)                                                                                                                           | Create a management group in seconds using this command.                                                                           |
| [Remove-AzResource](https://azurelessons.com/remove-azresource/)                                                                                                                               | Removes the specified Azure resource.                                                                                              |
| [New-AzRoleAssignment](https://azurelessons.com/new-azroleassignment/)                                                                                                                         | Helps you to assign an RBAC role to a specific principal for a specified scope.                                                    |
| [Remove-AzResourceLock](https://azurelessons.com/remove-azresourcelock/)                                                                                                                       | Removes a lock from an Azure resource.                                                                                             |
| [New-AzResource](https://azurelessons.com/new-azresource/)                                                                                                                                     | Modify your Azure resource group in seconds.                                                                                       |
| [Export-AzResourceGroup](https://azurelessons.com/export-azresourcegroup/)                                                                                                                     | Save your resource group as a template with a JSON file format.                                                                    |
| [Get-AzRoleDefinition](https://azurelessons.com/get-azroledefinition/)                                                                                                                         | Retrieve the list of Azure RBAC roles that are available that you can assign.                                                      |
| [Get-AzRoleAssignment](https://azurelessons.com/get-azroleassignment/)                                                                                                                         | Quickly create an Azure resource like a website or an Azure SQL database/server in a resource group.                               |
| [Get-AzResourceProvider](https://azurelessons.com/get-azresourceprovider/)                                                                                                                     | Quickly get the Azure resource provider.                                                                                           |
| [Get-AzResourceLock](https://azurelessons.com/get-azresourcelock/)                                                                                                                             | Retrieve the Azure resource locks.                                                                                                 |
| [Get-AzResource](https://azurelessons.com/get-azresource/)                                                                                                                                     | Get a list of all the Azure resources.                                                                                             |
| [Get-AzConfig](https://azurelessons.com/get-azconfig/)                                                                                                                                         | Retrieve the lists of all the configs of your Azure PowerShell.                                                                    |
| [Get-AzContext](https://azurelessons.com/get-azcontext/)                                                                                                                                       | Retrieve the metadata details.                                                                                                     |
| [Add-AzureAccount](https://azurelessons.com/add-azureaccount/)                                                                                                                                 | Add the Azure account to the Windows PowerShell.                                                                                   |
| [Set-AzContext](https://azurelessons.com/set-azcontext/)                                                                                                                                       | It helps you set the subscription, tenant, and environments for different PowerShell commands for your current PowerShell session. |
| [connect-AzAccount](https://azurelessons.com/connect-azaccount/)                                                                                                                               | It helps you help you connect to Azure with one particular authenticated account.                                                  |
| [Disconnect-AzAccount](https://azurelessons.com/disconnect-azaccount/)                                                                                                                         | Disconnect an Azure account that you are connected to currently.                                                                   |
| [Clear-AzContext](https://azurelessons.com/clear-azcontext/)                                                                                                                                   | Delete/clear all the Azure credentials, subscription and account details, etc.                                                     |
| [Get-AzLocation](https://azurelessons.com/get-azlocation/)                                                                                                                                     | Retrieve the location details and their supported resource providers.                                                              |
| [Get-AzDeployment](https://azurelessons.com/get-azdeployment/)                                                                                                                                 | Retrieve the deployment details under the current subscription.                                                                    |
| [Start-ADSyncSyncCycle](https://azurelessons.com/start-adsyncsynccycle/)                                                                                                                       | Helps to force Sync Azure AD Connect or to run a sync cycle manually.                                                              |
| [Get-AzureADMSGroup](https://azurelessons.com/get-azureadmsgroup/)                                                                                                                             | Get the details of the Azure AD groups via the MS Graph.                                                                           |
| [S](https://azurelessons.com/set-azureadmsgroup/)[et-AzureAD](https://azurelessons.com/set-azureadmsgroup/)[MSGroup](https://azurelessons.com/set-azureadmsgroup/)                             | Modify different properties of the Azure AD group.                                                                                 |
| [Get-AzureADServicePrincipal](https://azurelessons.com/get-azureadserviceprincipal/)                                                                                                           | Retrieve the list of service principals from your Azure Active Directory.                                                          |
| [Get-AzureADMSDeletedDirectoryObject](https://azurelessons.com/get-azureadmsdeleteddirectoryobject/)                                                                                           | Get the soft deleted AD object from the Azure Active Directory.                                                                    |
| [Get-AzSubscription](https://azurelessons.com/get-azsubscription/)                                                                                                                             | Retrieve the List of Azure Subscriptions.                                                                                          |
| [Get-azurermsubscription](https://azurelessons.com/get-azurermsubscription/)                                                                                                                   | Get the subscription details that the current account can access.                                                                  |
| [Connect-AzureRMAccount](https://azurelessons.com/connect-azurermaccount/)                                                                                                                     | Helps to connect to the authenticated account for using the Azure RM cmdlets.                                                      |
| [Select-AzureSubscription](https://azurelessons.com/select-azuresubscription/)                                                                                                                 | Can get you the lists of all the role assignments under your subscription or a specific scope.                                     |
| [New-AzureADMSInvitation](https://azurelessons.com/new-azureadmsinvitation/)                                                                                                                   | Can help you to invite an external user to your Azure Active directory.                                                            |
| [Connect-msolservice](https://azurelessons.com/connect-msolservice/)                                                                                                                           | Can help you to initiate a connection to your Azure Active Directory.                                                              |
| [Get-AzMetric](https://azurelessons.com/get-azmetric/)                                                                                                                                         | Can help you to retrieve the metric values of an Azure resource.                                                                   |
| [Get-AzSqlDatabase](https://azurelessons.com/get-azsqldatabase/)                                                                                                                               | Help you to set and clear your current and default Azure subscriptions.                                                            |
| [Get-AzSqlServer](https://azurelessons.com/get-azsqlserver/)                                                                                                                                   | Help you retrieve the Azure SQL database lists from your Azure SQL Database Server.                                                |
| [Get-AzStorageTable](https://azurelessons.com/get-azstoragetable/)                                                                                                                             | Can help you to create a storage table quickly.                                                                                    |
| [Set-AzStorageAccount](https://azurelessons.com/set-azstorageaccount/)                                                                                                                         | Use this Azure PowerShell command to modify or update your Azure Storage account.                                                  |
| [Get-AzActivityLog](https://azurelessons.com/get-azactivitylog/)                                                                                                                               | Can help you to get the lists of available storage tables associated with the specified Storage account.                           |
| [Get-AzADGroupMember](https://azurelessons.com/get-azadgroupmember/)                                                                                                                           | Help you retrieve the Activity Log event lists from your Azure Subscription.                                                       |
| [New-AzADGroup](https://azurelessons.com/new-azadgroup/)                                                                                                                                       | Can help you to create a new Azure AD group.                                                                                       |
| [New-AzADUser](https://azurelessons.com/new-azaduser/)                                                                                                                                         | Can help you to create a new Azure AD user.                                                                                        |
| [Add-AzADGroupMember](https://azurelessons.com/add-azadgroupmember/)                                                                                                                           | Helps you to add members to an Azure AD group.                                                                                     |
| [Get-AzADAppCredential](https://azurelessons.com/get-azadappcredential/)                                                                                                                       | Help you to list the members from an Azure AD group.                                                                               |
| [Start-AzVM](https://azurelessons.com/start-azvm/)                                                                                                                                             | It helps to start your Azure VM.                                                                                                   |
| [Get-AzWebApp](https://azurelessons.com/get-azwebapp/)                                                                                                                                         | It helps you to retrieve information about your Azure Web App.                                                                     |
| [Set-AzWebApp](https://azurelessons.com/set-azwebapp/)                                                                                                                                         | It can help you modify your Azure Web App.                                                                                         |
| [Get-AzApplicati](https://azurelessons.com/get-azapplicationinsights/)[o](https://azurelessons.com/get-azapplicationinsights/)[nInsights](https://azurelessons.com/get-azapplicationinsights/) | It helps you to return the Application Insights components.                                                                        |
| [Get-AzAppServicePlan](https://azurelessons.com/get-azappserviceplan/)                                                                                                                         | It helps to retrieve an Azure App Service plan in the resource group that you have specified.                                      |
| [Get-Aduser](https://azurelessons.com/get-aduser/)                                                                                                                                             | It helps you quickly find the AD users in your domain.                                                                             |
| [Get-AzVirtualNetwork](https://azurelessons.com/get-azvirtualnetwork/)                                                                                                                         | It helps you helps to retrieve the lists of virtual networks under a resource group.                                               |
| [Get-AzVirtualNetworkSubnetConfig](https://azurelessons.com/get-azvirtualnetworksubnetconfig/)                                                                                                 | It helps you to retrieve the details of a subnet inside a Virtual network.                                                         |
| [New-AzAppServicePlan](https://azurelessons.com/new-azappserviceplan/)                                                                                                                         | It helps you retrieve the details of a subnet inside a virtual network.                                                            |
| [Get-AzKeyVaultSecret](https://azurelessons.com/get-azkeyvaultsecret/)                                                                                                                         | It can help you quickly create an App service plan for a specific region.                                                          |
| [Get-AzDisk](https://azurelessons.com/get-azdisk/)                                                                                                                                             | It helps you to retrieve the properties of a Managed disk.                                                                         |

| **Name**                                                                                                            | **Description**                                                                               |
| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| [Azure Powershell change subscription](https://azurelessons.com/azure-powershell-change-subscription/)              | Learn how the **Select-AZSubscription** command can be used to change the Azure subscription. |
| [How to get tenant id in Azure using PowerShell](https://azurelessons.com/get-tenant-id-in-azure-using-powershell/) | Check out how to get tenant id in Azure using PowerShell.                                     |
| [Azure PowerShell List Resource Groups](https://azurelessons.com/azure-powershell-list-resource-groups/)            | Learn how to list Resource Groups using the PowerShell command Get-AzResourceGroup.           |
