Hello Eric,
A possible solution for you would be to trap the exception thrown by Get-ADComputer and remove the device from SCCM in the catch block.
Example:
$ComputerName = 'MyTest'
$Domain = 'viamonstra.local'
try
{
Get-ADComputer -Identity $ComputerName -Server $Domain
}
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]
{
Write-Verbose -Message ('Device "{0}" not found in Active Directory domain {1}' -f $ComputerName, $Domain)
Write-Verbose -Message ('Removing device "{0}" from SCCM' -f $ComputerName)
...
}
Best,
Daniel