Quick script to remove duplicate computers between two LANDesk core servers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
$mycreds = Get-Credential -Credential "Domain\account"
 
$ldWSold    = New-WebServiceProxy -uri http://oldcore.example.com/MBSDKService/MsgSDK.asmx -Credential $mycreds
$ListOlds   = $ldWSold.ListMachines("").Devices
 
$ldWSNew    = New-WebServiceProxy -uri https://newcore.example.com/MBSDKService/MsgSDK.asmx -Credential $mycreds
$ListNews   = $ldWSNew.ListMachines("").Devices
  
#GUID                                   DeviceName      DomainName           LastLogin
foreach ($ListOld in $ListOlds) {
    foreach ($ListNew in $ListNews) {
        If ($ListNew.DeviceName -notlike "newcore*") {
            If ($ListOld.DeviceName -eq $ListNew.DeviceName) {
                If ($ListOld.GUID -ne "Unassigned") {
                    write-host $ListOld.DeviceName "=>" $ListOld.GUID               
                    $ldWSold.DeleteComputerByGUID($ListOld.GUID)
                }
            }
        }
    }
}