PowerShell scripts – delete computer account in Active Directory

PowerShell scripts – delete computer account in Active Directory

  • Comments 2

$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = $dom.GetDirectoryEntry()
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.filter = "(&(objectclass=computer)(name=windowsserver))"
$search.findall() | %{$_.GetDirectoryEntry() } | %{$_.DeleteObject(0)}

Comments
Page 1 of 1 (2 items)
Leave a Comment
  • Please add 3 and 2 and type the answer here:
  • Post