Today I got a query on My Youtube Channel on How to create a Powershell script to Disable AD User Account. There are multiple ways to do it lets see How we can Disable AD User Account with Powershell.

To disable Active Directory user account by user’s samAccountName and DistinguishedName, disable AD Users from specific OU, and disable Bulk AD users from CSV file using PowerShell script.

You can disable an AD account by using the Active Directory powershell cmdlet Disable-ADAccount.

The Disable-ADAccount cmdlet disables an Active Directory user, computer, or service account. The Identityparameter specifies the Active Directory user, computer service account, or other service account that you want to disable. You can identify an account by its distinguished name (DN), GUID, security identifier (SID), or samAccountName.

Disable AD User Account with samAccountName

Disable AD User Account with DistinguishedName

Disable Active Directory Users from Specific OU

Disable Bulk AD Users from CSV file using Powershell Script

  • Consider the CSV file Users.csv which contains set of Active Directory users to disable with the attribute samAccountName.
  • Copy the below Powershell script and paste in Notepad file.
  • Change the Users.csv file path with your own csv file path.
  • SaveAs the Notepad file with the extension .ps1 like Disable-Bulk-AD-Users-FromCSV.ps1 

  • Now run the Disable-Bulk-AD-Users-FromCSV.ps1 file in Powershell to Disable Bulk Active Directory users from CSV file.

Note: This Script is in C:\Scripts Folder

This Above Command will Help and Soon I will work upon the Script and show you’re up in a Video How to Do Live in Front of you which will make things easy.

Anytime you have any questions just shoot the question and will be happy to assist you further on this hope this post of Powershell script to Disable AD User Account.

newsletter-aik

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!