Removing Agent, which the coresponding target system isnt existing any more

Removing Agent, which the coresponding target system isnt existing any more

avatar

Good moring PSU-Community,

i have a question regarding agents and their handling after the target system got deleted. Since i wasn`t able to find information regarding this in the documentation or the forum, i decided to open up this thread.

Right know the agent ist marked as offline under platform/computer in the PSU-web-UI and i would like to delete it or mark it as deleted. As far as i can tell there is no button in the web-UI or PowerShell-Cmdlet in the "Universal"-module to do that. When i use the command "Get-PSUComputers" and filter it to the coresponding agent, there is a property called "deleted", which right know is set to "false". With "Set-PSUComputer" i also can`t change the mentioned property and as far i an tell ther is no other command for deleting or softdeleting the agent-computer.

Can you tell me the intended way to clean up old agents?

Thanks in advance and greets from Germany,

Markus

All Comments (6)

avatar

Hi Markus,

Thank you for raising this.

I reviewed the current v5 documentation for Agents, Event Hubs, and Platform > Computers. I can confirm that Agents are registered when they connect to the Event Hub, and the Computers page documents computer groups, tags, and maintenance mode. However, I do not see a publicly documented v5 method to remove or soft-delete an old offline agent/computer record from the UI or through a Remove-PSUComputer style cmdlet.

Because of that, I would not recommend manually changing the PowerShell Universal database unless we confirm that approach with the development team first.

Could you please share the following details?

PSU version:
Database type: SQLite, SQL Server, or PostgreSQL
Whether this is a PSU Agent/Event Hub connection or a PSU node from a multi-node installation
A sanitized output of the affected record from Get-PSUComputers

I will check the intended supported cleanup path for this scenario and whether the deleted property is intended to be managed internally only or exposed through a supported operation.

https://docs.powershelluniversal.com/config/agent
https://docs.powershelluniversal.com/api/event-hubs
https://docs.powershelluniversal.com/platform/computers

Best regards,
Ruben Tapia

avatar

Hello Ruben,

thanks for the reply.

Currently i am running PSU-Version 2026.2.0.0 (i ll update to 2026.2.1.0 probaly next week) as a single-server-installation with the database on an SQL Server 2025 Enterprise (using AlwaysOn Availbility Groups). In my case its an PSU-Agent (same Version as PSU-server) connected through an Event Hub. The Agent, which i want to remove, will just show up as offline, because the system (a vm in this example) got deleted after the services got migrated to a new vm.

Here is the example you asked for:

Get-PSUComputer |  Where-Object {($_.Maintenance -eq $false) -and ($_.Status -eq "Offline") -and ($_.Type -eq "Agent")}
#Output
<#
Id                    : 3
Name                  : <Hostname of deleted VM>
HeartBeat             : 01.07.2026 05:08:06
Status                : Offline
GrpcPort              : 0
LoadingInfo           :
Maintenance           : False
Deleted               : False
LoginErrorMessage     :
Tags                  :
HangfireServerId      :
HangfireWorkerCounter : 0
Version               : 2026.2.0
FileSyncTimestamp     : 01.01.0001 00:00:00
ReadOnly              : False
DeploymentVersion     :
DeploymentName        :
GitSettings           : <git setting>
GitBranch             : <git branch>
Type                  : Agent
GitSshKey             :
EditMode              : Gui
DataItems             : 
#> 


Let me know it you need further information regarding my case.

Thanks for the support and best regards,
Markus

avatar

Hi Markus,

Thank you for the additional details.

That helps confirm the scenario. Since this is a PSU Agent connected through an Event Hub, and the original VM no longer exists, the offline record appears to be an orphaned agent/computer registration rather than an active PSU node.

At the moment, I do not see a publicly documented v5 method to remove or soft-delete this type of offline Agent record from the UI or through a supported Universal module cmdlet. Because your environment is using SQL Server with AlwaysOn Availability Groups, I would not recommend modifying the database directly unless we confirm the supported path with the development team first.

I will review this internally from two angles:

First, whether there is already a supported cleanup mechanism that is not currently documented or exposed in the UI.

Second, whether this should be handled as a product improvement request, for example, adding a supported option to remove stale/offline Agent records. If the required change is more complex because of how agent registration, historical data, or computer targeting is stored, we may need to document it as a current product limitation instead.

In the meantime, if this offline agent is causing a functional impact beyond appearing in Platform > Computers, such as affecting Computer Groups, target selection, scripts, schedules, or `Invoke-PSUCommand`, please let me know so I can include that in the internal review.

References reviewed:
https://docs.powershelluniversal.com/config/agent
https://docs.powershelluniversal.com/api/event-hubs
https://docs.powershelluniversal.com/platform/computers

Best regards,
Ruben Tapia

avatar

Hello @rubentapia

thanks for the answer. right know the orphaned agent dont have any functional impact on my end. As a workaround i am putting orphaned agent into the maintance mode and maybe i`ll tag the as well (i haven`t decided yet) till we have a final solution/procedure.

Best regards,
Markus

avatar
Hello @rubentapia

thanks for the answer. right know the orphaned agent dont have any functional impact on my end. As a workaround i am putting orphaned agent into the maintance mode and maybe i`ll tag the as well (i haven`t decided yet) till we have a final solution/procedure.

Best regards,
Markus


@markusburkhardt
Hi Markus,

Thank you for the update.

That workaround makes sense for now, especially since there is no functional impact on your end at the moment. Using Maintenance Mode and optionally tagging those orphaned agents is a reasonable temporary way to keep them identified and separated while we confirm the intended product behavior.

I have raised this internally with the development team to confirm whether there is a supported cleanup path today for orphaned PSU Agent records, or whether this should be handled as a feature request or documented as a current product limitation.

Once I have a clearer answer, I will update this thread with the recommended path.

Best regards,
Ruben Tapia

avatar

Hi Markus,

I reviewed this internally with our development team. Based on that review, this scenario should be treated as a feature request rather than an existing supported cleanup workflow.

At the moment, the recommended workaround is to keep those orphaned Agent records in Maintenance Mode and optionally tag them so they can be clearly identified as stale/orphaned entries.

The development team will open an internal issue to track this request for a supported way to remove or clean up orphaned PSU Agent records in the future.

Best regards,
Ruben Tapia