Get
all the computer in SCCM put them in a variable do a for each and ask AD if the
computer is found and active. If not delete it form SCCM.
import-module
ActiveDirectory
Import-Module
$env:SMS_ADMIN_UI_PATH.Replace(“\bin\i386″,”\bin\configurationmanager.psd1”)
$computers = (get-cmdevice).name
foreach ($computer in $computers)
{
try
{
Get-ADComputer -Identity $computer -ErrorAction Stop >$null
}
catch
{
write-host “$computer is not in AD”
}
}
Comments