We need to remove all devices that are associated with a single origin and would like to do it via script.
Release : 20.4
Component : UIM - discovery_server
1. Create a Dynamic group with a Device filter by origin, and save
2. Select the new group in OC and click on the three dots to the far right and select edit columns to include cs_id, and select to save.
3. Once listed in the OC groups view, select the 3 dots again and then selected the Export option and Device Detail > OK (this will save as an Excel file)
4. Open the file with Excel and grab the list of cs_ids
Alternatively if access to the database is available, the following can be used to get the cs_ids:
select
cr.robot,
cr.origin,
cd.cs_id
from CM_NIMBUS_ROBOT CR
join CM_DEVICE CD on cd.dev_id = cr.dev_id
where origin like '%origin%'
5. Copy the cs_ids for devices to a text file and name it cs_ids.txt
6. Created the following batch file with the pu command and the discovery_server remove_master_devices_by_cs_ids callback.
Note: Replace <password> with your UIM's administrator password
@ECHO OFF
SET PASSWORD=<password>
FOR /F "tokens=*" %%A in (cs_ids.txt) do (
pu.exe -u administrator -p %PASSWORD% discovery_server remove_master_devices_by_cs_ids %%A
)
6. Run the batch file with single cs_id in the cs_ids.txt file and confirm that device is deleted from the Operator Console Inventory
7. Run the batch with the full list
The pu command is generally run from the nimsoft/bin directory.
If you are running this from other than the primary and or the discovery_server is located on another robot, it will require the fill path in the pu command:
pu.exe -u administrator -p %PASSWORD% /<uim_domain>/<uim_hub>/<uim_robot>/discovery_server remove_master_devices_by_cs_ids %%A