Triage and Remediation
Remediation
Using Console
Using Console
To remediate inactive users in Azure Active Directory (Azure AD) using the Azure console, follow these steps:
- Sign in to the Azure portal (portal.azure.com) using your Azure AD administrator account.
- In the left-hand menu, click on “Azure Active Directory” to open the Azure AD dashboard.
- In the Azure AD dashboard, click on “Users” to view the list of users in your directory.
- Sort the users by the “Last sign-in” column to identify the inactive users. Users with no sign-in activity will have a blank or old date in this column.
- Select the inactive users you want to remediate by clicking on their names or using the checkboxes beside their names.
- Once the users are selected, click on the “Delete” button at the top of the user list.
- In the confirmation dialog, review the selected users and click on “Delete” to remove them from Azure AD.
- After the users are deleted, you may want to review any associated resources or permissions they had and update or remove them accordingly.
- Additionally, consider enabling Azure AD Premium’s “Azure AD Identity Protection” feature to proactively detect and remediate risky sign-in activities.
Using CLI
Using CLI
To remediate inactive users in Azure Active Directory (Azure AD) using Azure CLI, follow these steps:
- Install Azure CLI: If you haven’t already, install the Azure CLI on your local machine by following the instructions provided by Microsoft.
-
Sign in to Azure: Open a terminal or command prompt and sign in to your Azure account by running the following command:
-
Select the Azure subscription: If you have multiple Azure subscriptions, use the following command to select the appropriate subscription:
-
List inactive users: Use the following command to list all inactive users in Azure AD:
-
Review the list: Examine the output of the previous command to identify the inactive users that need to be remediated. Note down the
objectId
of each inactive user. -
Disable inactive users: For each inactive user identified in the previous step, run the following command to disable the user:
Replace
<objectId>
with the actualobjectId
of the inactive user. -
Verify the changes: To ensure that the users have been disabled, you can use the
az ad user show
command to check the accountEnabled status of each user:Replace<objectId>
with the actualobjectId
of the user. - Repeat step 6 and 7 for each inactive user identified in step 5.
Using Python
Using Python
To remediate inactive users in Azure Active Directory (Azure AD) using Python, follow these steps:Make sure you have the necessary permissions to manage users in Azure AD. Adjust the code as necessary to suit your specific requirements and environment.
-
Install the required libraries:
- Install the Azure Identity library:
pip install azure-identity
- Install the Azure Management IAM library:
pip install azure-mgmt-authorization
- Install the Azure Identity library:
- Import the necessary modules in your Python script:
- Authenticate with Azure using the DefaultAzureCredential:
- Define a function to get the list of inactive users:
- Define a function to disable the inactive users:
- Specify the number of days of inactivity after which a user should be considered inactive:
- Call the
disable_inactive_users
function with the specified number of inactive days: