Deleting an Orion Agent and its Node using Powershell SDK instead of GUI

I want to replicate the behavior in the GUI that occurs if I go to:


Select an Agent, and click Delete. This not only removes the Agent registration, it also deletes the Node and cleans up everything associated with it.

I THINK the correct way to do that with Powershell is:

invoke-swisverb $swis Orion.AgentManagement.Agent delete @($agentid)

Where $swis is the SwisConnection, Orion.AgentManagement.Agent is the Entity, delete is the Verb, and $agentid is the integer in the AgentId column in the Orion.AgentManagement.Agent table.

Am I correct in my syntax? Will this accomplish the same thing that using the GUI does when I select an Agent and click Delete? If not, what else would I need to do?

  • In the API, deleting the agent and deleting the associated node are two separate operations. The agent management UI combines them.

    Your PowerShell for deleting the agent looks correct. You can also do it by getting the Uri for the agent record and calling "Remove-SwisObject $swis $agentUri" on it. It leads to the same place.

    To delete the Node, you need the Uri for the node. Given the agent ID, you can get the node Uri with a query like this:

    SELECT Agent.Node.Uri AS Uri

    FROM Orion.AgentManagement.Agent

    WHERE AgentId = 1234

    (Note that you need to run this query before you delete the agent, because it won't work after!)

    Then you can remove the node like this:

    Remove-SwisObject $swis $nodeUri

  • Tdanner -

    Thanks for getting back to me and my apologies for replying so late. This is exactly the information I was looking for and I appreciate you taking the time to respond :-)

  • I like this and I am trying to implement this in my environment. How are you obtaining the the Agent ID to delete? I don't see a specific variable to use. Or perhaps there is a custom variable I can create using SWQL? Any help would be greatly appreciated!