Subdomain 1.2: Manage users and groups
1.An administrator needs to remove a large number of users who have left the company. The user list is in a CSV file. The administrator wants to use Microsoft Graph PowerShell to perform the deletion. Which cmdlet should be used?
- A.Remove-MgUser
- B.Delete-MgUser
- C.Disable-MgUser
- D.Set-MgUser -AccountEnabled $false
Show answer & explanation
Correct answer: A — Remove-MgUser
- A. Correct. Remove-MgUser is the Microsoft Graph PowerShell cmdlet used to permanently delete a user object from the directory. It can be used in a script to delete multiple users from a CSV file.
- B. Incorrect. Delete-MgUser is not a valid cmdlet in Microsoft Graph PowerShell. The correct cmdlet for deleting a user is Remove-MgUser.
- C. Incorrect. Disable-MgUser is used to disable a user account, preventing sign-in, but it does not remove the user object from the tenant. The account remains and can be re-enabled.
- D. Incorrect. Set-MgUser -AccountEnabled $false disables the user account but does not delete it. The user object persists in Microsoft 365, so this does not meet the requirement to remove users.