PMC Supporting PowerShell Scripts

The three PowerShell scripts that follow are supplied with PMC to support your installation. The use of these is optional:

  • Deactivate Duplicate Agents
  • Deactivate Inactive Agents
  • NodeDiagnosticsLogsDownload

Deactivate Duplicate Agents

The script to deactivate agents with multiple hostnames is called DeactivateDuplicateAgents.ps1 and is supplied by BeyondTrust in the PowerShell folder.

The script returns a list of agents that it has identified as duplicates. In each set of duplicate agents, the ones with the oldest timestamps are flagged for deactivation. These agents are immediately removed from PMC. The script pauses for five minutes before it deactivates the agents to ensure that other tasks aren't running. Lastly, the script confirms the number of agents that it has deactivated. On deactivation, the Authorization Status of the agent changes to Deactivated. You can view the Authorization Status of an agent in the Computer Details page in PMC.

This script accepts five parameters:

  • client_id
  • client_secret
  • tenant_id
  • cloudServiceDnsName
  • platformApiPort

You can run the script in PowerShell without the parameters and you are prompted for each one in turn or you can build the full command line before pasting it into PowerShell.

.\DeactivateDuplicateAgents.ps1 -client_id "<client_id>" -client_secret "<client_secret>" -tenant_id "<tenant_id>" -cloudServiceDnsName "<cloudServiceDnsName>" -platformApiPort "<port number>"

The Application ID and API Key fields employ the client_id and client_secret, respectively.

client_id

This is the Application ID that is below the Enable API key access check box in the Remove Access Settings page in PMC.

client_secret

This is the API Key in the PMC Settings page.

 

tenant_id

For Windows Directory and LDAPS, the GUID is generated by the deployment tool and you should have a note of it already.

cloudServiceDnsName

This is your PMC URL. Do not include the https:// or the port when entering. For example, pmc.example.com.

platformApiPort

This is the port number the API connects on. It is usually 8443.

For instructions on getting the GUID for Microsoft Azure authentication, please see PMC Authentication Prerequisites.

Deactivate Inactive Agents

The script to deactivate inactive agents is called DeactivateNonActiveAgents.ps1 and is supplied by BeyondTrust in the PowerShell folder.

When running, the script states that it's retrieving a list of agents that have not connected for the defined number of days (inactiveDays) since a date and time. The date and time value is the date of the system minus the number set for inactiveDays. It then details how many agents have been identified and confirms that it will request deactivation of a specified number of agents. The script pauses for five minutes before it deactivates the agents to ensure that other tasks aren't running. The script confirms the number of agents that it has deactivated. On deactivation, the Authorization Status of the agent changes to Deactivated. You can view the Authorization Status of an agent in the Computer Details page in PMC.

This script accepts six parameters:

  • client_id
  • client_secret
  • tenant_id
  • cloudServiceDnsName
  • inactiveDays
  • platformAPIPort

You can run the script in PowerShell without the parameters and you'll be prompted for each one in turn, or you can build the full command line before pasting it into PowerShell.

.\DeactivateNonActiveAgents.ps1 -client_id "<client_id>" -client_secret "<client_secret>" -tenant_id "<tenant_id>" -cloudServiceDnsName "<cloudServiceDnsName>" -inactiveDays "<inactiveDays>" -platformApiPort "<port number>"

The Application ID and API Key fields employ the client_id and client_secret, respectively.

client_id

This is the Application ID that is below the Enable API key access check box in the Remove Access Settings page in PMC.

client_secret

This is the API Key in the PMC Settings page.

 

tenant_id

For Windows Directory and LDAPS the GUID is generated by the deployment tool and you should have a note of it already.

cloudServiceDnsName

This is your PMC URL. Do not include the https:// or the port when entering, for example test.pmc.example.com.

inactiveDays

This is the number of days the tenant has been inactive and must be a minimum of 15.

platformApiPort

This is the port number the API connects on. It should be 8443.

For instructions on getting the GUID for Microsoft Azure authentication, please see PMC Authentication Prerequisites.