0%
Delete a User Account

Delete a User Account

This guide shows you how to delete a user account in Active Directory with PowerShell.

10-15 min

Deleting User Accounts in Active Directory with PowerShell

This guide explains how to delete user accounts in Active Directory (AD) using PowerShell. You will learn how to delete a specific user, identify disabled accounts, and run bulk deletions with filters.


Commands for Deleting User Accounts

1. Delete a user account without confirmation

If you want to delete a user directly without confirmation, use -Confirm:$false to skip the confirmation prompts.

# Supprime le compte utilisateur "jlebon" sans demander de confirmation
Remove-ADUser -Identity jlebon -Confirm:$false
  • Purpose: Immediately delete the jlebon account from Active Directory without a confirmation prompt.
  • Explanation:
    • Remove-ADUser: Cmdlet that deletes a user in Active Directory.
    • -Identity jlebon: Identifies the user to delete by their identity name.
    • -Confirm:$false: Deletes the user without confirmation, which is useful for automation. Warning: Use with caution to avoid accidental deletions.

2. Delete a user account with confirmation

If you want an extra safeguard when deleting an account, omit -Confirm:$false. This lets you confirm each deletion.

Link copied!