![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) |
| Guest | 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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| removing a computer from the network in windows vista | Johnny Whaley | Vista networking & sharing | 4 | 07-20-2008 03:55 PM |
| I need the SID for all the computer accounts in AD!! | Gabe | VB Script | 4 | 06-06-2008 11:55 AM |
| removing computer from workgroup | tommygun | Vista networking & sharing | 1 | 02-21-2008 06:31 PM |
| Removing Loose program files from my computer | dyno12345 | Vista performance & maintenance | 0 | 08-02-2007 01:44 AM |
| Removing misnamed computer from networked connections | =?Utf-8?B?bWFydHlmZWxrZXI=?= | Vista networking & sharing | 0 | 09-14-2006 04:46 PM |