![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | removing computer accounts from AD I'm working on a script that involves unbinding machines from Active Directory. I'm Using UnjoinDomainOrWorkgroup from the win32_ComputerSystem class. The machine is successfully removed from the domain but the machine account is still in AD. When I pass a 2 to FUnjoinOptions the account is not disabled. The return value is 0 and I'm specifying domain admin credentials for the password and username. Any help is appreciated. Andrew Zirkel. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: removing computer accounts from AD To remove a computer account from AD look at something like this $cname = "Computer6" $compname = "(cn=$cname)" ## get the domain $dom = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain() $domain = $dom.GetDirectoryEntry() ## get the computer $searcher = new-object System.DirectoryServices.DirectorySearcher($domain, $compname) $computer = $searcher.FindOne() ## and delete $compdel = $computer.GetDirectoryEntry() $compdel.psbase.DeleteTree() If you know the distinguished name the code could be shortened -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Andrew Zirkel" wrote: > I'm working on a script that involves unbinding machines from Active > Directory. I'm Using UnjoinDomainOrWorkgroup from the win32_ComputerSystem > class. The machine is successfully removed from the domain but the machine > account is still in AD. When I pass a 2 to FUnjoinOptions the account is > not disabled. The return value is 0 and I'm specifying domain admin > credentials for the password and username. > > Any help is appreciated. > Andrew Zirkel. > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Removing accounts-where does the mail go? | Live Mail | |||
| removing a computer from the network in windows vista | Vista networking & sharing | |||
| removing computer from workgroup | Vista networking & sharing | |||
| Removing Loose program files from my computer | Vista performance & maintenance | |||
| Removing misnamed computer from networked connections | Vista networking & sharing | |||