Script to Release Licenses for Machines Using a CSV File
Cyber Crucible has created a Powershell Script that can take in a CSV file path containing Net bios machine names to automatically release licenses from.
Script Arguments
The script takes in a few arguments in order to run:
CSVPath
This is the path of the CSV file that contains the machine names of agents whose licenses should be released
The format of this file should be .csv and the delimiter should be a comma
MachineNameHeader
This is the header name of the column that contains the machine names
The CSV file must have a header row
AgentLastActiveDays (Optional)
By default, the script will not release the licenses of agents with matching machine names that have called in within the last 30 days. You may pass a different number to this argument if 30 days is not desired
RefreshToken
Your refresh token can be found on the Rest Integration Page. See the “How to find Your Refresh Token” section for more
CaseSensitive (Optional)
A Switch parameter indicating if the script should use case-sensitive matching on the given machine names from the CSV file when finding the corresponding agents.
By default, the script will use case-insensitive matching
TrainingMode (Optional)
A Switch parameter indicating if the machine names are training mode data.
Only include this argument if the machine names are for training mode data, otherwise do not include
DemoMode (Optional)
A Switch parameter indicating if the machine names are demo mode data.
Only include this argument if the machine names are for demo mode data, otherwise do not include
Download the Script
How to Run the Script
After downloading the script and finding your refresh token, open Powershell and navigate to where you have downloaded the script. Then you can run the script with the arguments defined above. An example command to run the script can be seen below:
.\ReleaseLicensesFromMachines.ps1 -CSVPath "C:\Users\user\Documents\csvFile.csv" -MachineNameHeader "MachineName" -RefreshToken "token"
The script will look for your agents that have matching machine names from the CSV file and remove their licenses. The script may take a few minutes to finish running and should be left running until it finishes.
Please note that if you have multiple agents with the same machine name, all of these agents will have their license removed if the machine name is included in the CSV file. Agents with matching machine names that have called in within the specified number of days in the AgentLastActiveDays argument (Default of 30 days, see argument definition above) will not have their license removed.
How to find Your Refresh Token
You will need a refresh token to be able to run the script, which can be found on our website on the Rest Integration page: