Skip to main content

Overview

This document describes the process for removing VSA Agents from the environment that have been offline for more than 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, not in $MachineGroupException groups, etc.) and runs the VSAAPI function Remove-VsaAgent, which removes them from the VSA without first uninstalling the agent. Exclusion filters can be applied for OsType, OsInfo (Build caption), IP Address, MAC Address, Country, Domain, and Workgroup. Filters are applied individually; applying more than one filter will remove both pools from the removal list. For example, providing -OsTypeExclusion '10' and -DomainWorkgroupExclusion 'proval' will retain all Windows 10 machines from the list and all machines on the ProVal domain or Workgroup.

Payload Usage

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

This command removes agents that have been offline for 30 days in all groups except proval.development. It does not remove any endpoints running Windows 11.

Parameters

ParameterRequiredDefaultTypeDescription
BaseURLTrueStringVSA URL
VsaUserNameTrueStringUser with API Access
RestApiTokenTrueStringREST API Token for User
OfflineDaysFalse60IntAgent idle days for removal
MachineGroupExceptionFalseString ArrayGroups to exclude from agent removal
OsTypeExclusionFalseString ArrayExclude agents from removal based on their OsType field. This can be a partial match. Example Syntax: 10 (Windows 10), 2022 (Windows Server 2022), Mac (Mac OS X, All Versions)
OsInfoExclusionFalseString ArrayExclude agents from removal based on their OsInfo field. This can be a partial match. Example Syntax: Enterprise, Professional, Server, 19077 (All Windows Machines at build 19077), 19H2026 (All Mac OS X 10.15.7 machines)
ComputerNameExclusionFalseString ArrayExclude agents from removal based on Machine Name. This can be a partial match.
IPAddressExclusionFalseString ArrayExclude agents from removal based on IP Address. This can be a partial address.
MacAddrExclusionFalseString ArrayExclude agents from removal based on MAC Address. This can be a partial address.
CountryExclusionFalseString ArrayExclude agents from removal based on Country. This can be a partial match.
DomainWorkgroupExclusionFalseString ArrayExclude agents from removal based on Domain or Workgroup Name. This can be a partial match.

Output

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

./Remove-VsaStagnantAgent-log.txt

Attachments

Procedure_Stagnant_Agent_Removal_(Deprecated).xml