import depuis ancien GitHub
This commit is contained in:
21
CoreMigration-RemoveDuplicateComputer/readme.md
Normal file
21
CoreMigration-RemoveDuplicateComputer/readme.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# removeduplicate.ps1 — Remove Duplicate Devices
|
||||
|
||||
Delete duplicate computer objects left on an **old Core** after migrating to a **new Core**.
|
||||
The script connects to both Cores via the legacy SOAP endpoint (`MBSDKService/MsgSDK.asmx`), compares by `DeviceName`, and deletes the matching device from the old Core (skips names starting with `newcore`, and ignores `GUID = "Unassigned"`).
|
||||
|
||||
## Requirements
|
||||
- An account with rights to list devices and delete computers.
|
||||
- Windows PowerShell 5.1.
|
||||
|
||||
## Configure
|
||||
Edit the two endpoints in the script:
|
||||
```powershell
|
||||
$ldWSold = New-WebServiceProxy -Uri http://oldcore.example.com/MBSDKService/MsgSDK.asmx -Credential $mycreds
|
||||
$ldWSNew = New-WebServiceProxy -Uri https://newcore.example.com/MBSDKService/MsgSDK.asmx -Credential $mycreds
|
||||
```
|
||||
|
||||
## Run
|
||||
Edit the two endpoints in the script:
|
||||
```powershell
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\removeduplicate.ps1
|
||||
```
|
||||
23
CoreMigration-RemoveDuplicateComputer/removeduplicate.ps1
Normal file
23
CoreMigration-RemoveDuplicateComputer/removeduplicate.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# http://localhost/MBSDKService/MsgSDK.asmx?WSDL/GetMachineData
|
||||
|
||||
$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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user