{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":32097,"path":"it-service-management/devops-change-velocity/delete-orphan-alias.md","title":"Delete orphan connection and credential aliases","bundle":null,"doc_type":null,"release":"australia","body":"\n# Delete orphan connection and credential aliases\n\nDelete the connection and credential aliases that do not label any connection or credential record by running a background script. This helps you in freeing up space in your system.\n\n## Before you begin\n\nRole required: System Admin \\(admin\\)\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Definitions** &gt; **Scripts - Background**.\n\n2.  Select the scope as **global**.\n\n3.  Enter the following script in the **Run script \\(JavaScript executed on server\\)** pane.\n\n    ```\n    deleteOrphanAliases();\n    function deleteOrphanAliases() {\n        var orphanAliases = new GlideRecord('sys_alias');\n        orphanAliases.addEncodedQuery(\"nameSTARTSWITHDevOps-_-\");\n        orphanAliases.query();\n        while(orphanAliases.next()) {\n            if (!checkIfAliasHasConnection(orphanAliases.getUniqueValue()))\n                orphanAliases.deleteRecord();\n        }\n    };\n    function checkIfAliasHasConnection(sysAliasId) {\n        var httpToolConnGR = new GlideRecord(\"http_connection\");\n        httpToolConnGR.addEncodedQuery(\"connection_alias=\" + sysAliasId);\n        httpToolConnGR.query();\n        if (httpToolConnGR.next())\n            return true;\n        return false;\n    };\n    ```\n\n4.  Select **Run script**.\n\n\n**Parent Topic:**[Managing DevOps Change Velocity](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/devops-change-velocity/using-devops-change-velocity.md)\n\n"}}