0

PowerShell Code to Change Timer Intervals

Hi,

Here is the PowerShell code I wrote to change the timer intervals. I'm interested to find out if there are better methods for doing this.

# Set the new timer in ms. Default is 30000 ms (30 Seconds).
$NewTimerInterval = "10000"

$Timers = @("Name           = Default","Name           = GPU usage")
$ConfigFile = "${env:ProgramFiles}\vast limits\uberAgent\uberAgent.conf"
$FileContent = Get-Content "$ConfigFile"
$ChangeMade = $False
ForEach ($Timer in $Timers) {
  $LineNumber = 0
  $LineNumber = $FileContent | Select-String -Pattern $Timer | Select-Object -ExpandProperty LineNumber
  If ($LineNumber -gt 0) {
    $FileContent[$LineNumber -1 + 2] = ($FileContent[$LineNumber -1 + 2] -replace '\d+',"$NewTimerInterval")
    write-verbose "Changed the `"$Timer`" timer to an interval of $NewTimerInterval ms" -verbose
    $ChangeMade = $True
  }
}
If ($ChangeMade) {
  Set-Content "$ConfigFile" $FileContent
  Write-Verbose "Restarting the uberAgent service..." -Verbose
  stop-service "uberAgentSvc" -force
  start-service "uberAgentSvc"
}

Cheers,

Jeremy

1 comment

  • 0
    Avatar
    Dominik Britz

    Hi Jeremy,

    There isn't a more elegant solution at the moment. But, we are working on a feature where the agent pulls config files from a central share and applies them automatically.

    It's planned for the next version, we can't name any dates, though.

    Best regards

    Dominik

     

Please sign in to leave a comment.