Ghost Solution Suite

  • 1.  Removing Computer Account from Domain

    Posted Jun 12, 2023 10:06 AM

    Good morning!

    I am curious if anyone has a good way to remove computer accounts from the domain during the imaging process? In theory I would like to do this before setup.exe for Windows is executed on the machine. I have found some PowerShell scripts, but with the ones I've found, you have to specify the computer name each time you run it. If there is a way to have it check/remove the computer account of the target machine instead of having to specify the computer name each time, that would be ideal. Any thoughts, ideas suggestions welcome...thanks!

    Matt



  • 2.  RE: Removing Computer Account from Domain

    Posted Jun 16, 2023 01:40 PM
    Edited by Ed-White Jun 16, 2023 01:53 PM

    Hi Matt,

    We just setup a task to copy the powershell script to the computer, execute the file on the local machine, then delete the script after.  That way the script always uses the local computer name.  We use a domain account that can only add or remove objects and change its password on a regular basis.  I included a sample of the ps script we run below.

    Later

      Ed


    $domain = "DS.WHATEVER.WHATEVER"
    $password = "YOUR-PASSWORD" | ConvertTo-SecureString -asPlainText -Force
    $username = "$domain\DOMAIN-ACCOUNT" 
    $credential = New-Object System.Management.Automation.PSCredential($username,$password)
    $joined = (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
    if ($joined -eq $true) {
      Remove-Computer -Credential $credential -passthru -force
      }




  • 3.  RE: Removing Computer Account from Domain

    Posted Jun 20, 2023 08:47 AM

    Thanks for the feedback....I'll give it a shot!