I'm glad you like my solution.
For the agentTotal variable you can make a mandatory script parameter like this:
[Parameter(Mandatory=$true)][String]$AgentTotal,
Or you can use the Read-Host cmdlet to read the value:
$AgentTotal=Read-Host-Prompt"Enter total agent number"