Are you looking to clean up unused or stale computer accounts from your Active Directory environment?
In this video, I’ll show you how to use a simple yet powerful PowerShell script to delete multiple computer objects from Active Directory in bulk using a text file. This method is ideal for system administrators who want to automate AD cleanup and improve domain hygiene.
✅ What You’ll Learn:
How to import computer names from a .txt file
How to check if a computer exists in AD before deleting
How to use Remove-ADComputer safely
How to automate repetitive AD cleanup tasks
#powershell #activedirectory #sysadmin #ADCleanup #WindowsServer #ITAdmin #Automation #PowerShellScript #RemoveADComputer #TechTutorial #BulkDeleteAD #WindowsAdmin
Import-Module ActiveDirectory
Path to the text file
$computers = Get-Content "C:\temp\computers.txt"
foreach ($computer in $computers) {
if (Get-ADComputer -Identity $computer -ErrorAction SilentlyContinue) {
Remove-ADComputer -Identity $computer -Confirm:$false
Write-Host "Deleted: $computer"
} else {
Write-Warning "Computer not found: $computer"
}
}
• Find Windows Install Date Using Command Pr...
• PowerShell script to get SSL certificate d...
• How to get hostname from IP using ping com...
• How to Reset Admin Password on MacBook (ma...