Delete all assets/CIs for all asset types.

Version 3

    Verified Product Versions

    LANDESK Service Desk 7.8.xLANDESK Service Desk 2016.xLANDESK Asset Central 2016.x

    Question

    Need to delete all assets/CIs for all asset types.

    Answer

    -- Deletes all assets/CIs for all asset types.


     

    -- N.B. BEFORE RUNNING THIS SCRIPT you will need to ensure that the assets/CIs are not referenced from other objects,

    --          e.g. Incidents, Changes, Structures/Views, etc.

    -- If required, there are separate scripts to clear down these other objects.

     

    -- Clear down the user-defined business objects

    -- **************************************************

    -- ******** YOU WILL NEED TO AMEND THIS SCRIPT ******

    -- **************************************************

     

    -- Each database will be different. In this example we have 4 asset types:

    --          Server and PC are both versionable, Building and Room are not versionable.

     

    -- Versionable assets


    update usr_server set ubr_currentversion = null

    delete from usr_serverversion

    delete from usr_server

     

    update usr_pc set ubr_currentversion = null

    delete from usr_pcversion

    delete from usr_pc

     

    -- Non-Versionable assets


    delete from usr_building

    delete from usr_room

     

    -- All assets


    -- delete links to the CIs

    DELETE FROM cf_config_item_relationship

    DELETE FROM cf_customer_config_item

    DELETE FROM cf_supplier_config_item

    DELETE FROM cf_user_config_item

    update im_incident set im_config_item_guid=null where im_config_item_guid is not null

     

    -- finally delete the CIs

    update am_asset set am_current_version_guid = null

    DELETE FROM am_asset_version

    DELETE FROM am_asset             

                 

    update cf_config_item set cf_current_version_guid = null

    DELETE FROM cf_config_item_version

    DELETE FROM cf_config_item

     

    -- delete audit trail for all Asset/CI classes

    delete from tps_audit_trail where tps_class_type_id in

    (select md_guid from md_class_type where md_client_class like 'Touchpaper.ClientClasses.AssetManagement.%')

    delete from tps_audit_trail where tps_class_type_id in

    (select md_guid from md_class_type where md_client_class like 'Touchpaper.ClientClasses.ConfigManagement.%')

    Environment

    Console ITBM

     

    ***********************************************************

    This script be run by your database administrator and tested against a test copy of your database before applying live. When you apply to the live database, please ensure that no-one else is logged in and that a backup of the database has been taken. In the event of any problems you should restore from the backup copy.

     

    ***********************************************************