Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

Overview

This script removes VSA agents from the environment that have been offline for a specified number of days.

Requirements

The VSAAPI Module must be loaded.

Process

The script retrieves a list of agents that meet the specified criteria (offline for $OfflineDays days and not in $MachineGroupException groups) and executes the VSAAPI function Remove-VsaAgent, removing them from the VSA without first uninstalling the agent.

Payload Usage

./Remove-VsaStagnantAgent.ps1 -BaseURL https://vsa.provaltech.com -VsaUserName apiServiceAccount -RestApiToken abcd-efgh-ijkl-mnop -OfflineDays 30 -MachineGroupException proval.development

This command removes agents that have been offline for 30 days in all groups except proval.development.

Parameters

ParameterAliasRequiredDefaultTypeDescription
BaseURLTrueStringVSA URL
VsaUserNameTrueStringUser with API access
RestApiTokenTrueStringREST API token for the user
OfflineDaysFalse60IntNumber of idle days for agent removal
MachineGroupExceptionFalseString ArrayGroups to exclude from agent removal

Output

The output location for log, result, and error files is as follows:

./Remove-VsaStagnantAgent-log.txt