Hi, I am trying to find a way to search for an AD object in powershell and delete it, So i have figure that out kind of. But what I really want to do is have the script check if the object exists first then delete it and if it doesn't find it give me a message that it is not found.
FYI the naming scheme we have for computer objects all start with DT.
I am a extreme newb, please be gentle with me.
I have actually been tasked with removing the object from many different locations including crashplan, SCCM, JAMF , Symantec. But I am starting to crawl before I can walk.
code is attached, am I even close to achieving what I need??
thanks,
John
$computerName = Read-Host -Prompt 'Input computer name' GET-ADCOMPUTER -IDENTITY $computerName if ($computerName -eq "Cannot find an object with identity") {Write-Host "NO computer found"} elseif ($ComputerName -eq "DT*********") {REMOVE-ADCOMPUTER $computerName -confirm:$True}