Removing AD Computer Objects

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Scott Scott 2 years, 4 months ago.

  • Author
    Posts
  • #17330
    Profile photo of Scott
    Scott
    Participant

    Hi,

    I have a list of AD Computer Objects that i need to remove. Does anyone have a script to hand that will read through the list (txt) and remove them ?

  • #17331
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    To keep it simple, it's a one-liner:

    Get-Content C:\MyComputers.txt | foreach{Get-ADComputer -Identity $_ | Remove-ADComputer -WhatIf}

    After you validate the command is identify the correct object to remove, you can remove the -WhatIf to actually perform a move.

  • #17332
    Profile photo of Scott
    Scott
    Participant

    Fantastic – Cheers Rob!

You must be logged in to reply to this topic.