Once inactive computers are disabled and approved for deletion, the next step is to remove them from Active Directory. This process reduces security risks and improves management efficiency. It also offers benefits such as resource management, smoother migrations, etc.
For instance, during migration, excess inactive resource accounts can lead to additional costs and time-consuming processes. By removing the inactive computers, we can ensure that only active AD computers are migrated into the new AD environment.
Follow the steps below to remove the inactive computers from your Active Directory environment:
- Launch the Active Directory Users and Computers console.
- Navigate to the respective OU where the computer is located and right-click on the respective computer.
- Click on Delete to initiate the removal. Then, select ‘Yes’ in the confirmation window to delete the computer from Active Directory.
Manually navigating through multiple OUs to locate and delete inactive computers can be a tedious and time-consuming process. Instead, you can use their identity in the following PowerShell cmdlet to remove them from Active Directory.
Remove-ADComputer -Identity "<ComputerName>"
Use the below PowerShell script to remove multiple AD computer accounts quickly to avoid unnecessary replication and security risks.
$Computers = @("<ComputerName>", "<ComputerName>", "<ComputerName>")
foreach ($Computer in $Computers) {
Remove-ADComputer -Identity $Computer -Confirm:$false
}
To remove multiple computers with specific location property, you shall use the below PowerShell cmdlet.
Note: Replace the <LocationConfiguredinProperties> with the value defined in each computer’s Location filed under Properties page.
Get-ADComputer -Filter 'Location -eq "<LocationConfiguredinProperties>"' | Remove-ADComputer