Change timeout for script execution

If execution of a PowerShell script exceeds a certain timeout, Adaxes stops the execution with the following error message: The pipeline has been stopped. To change the timeout, use the below script.

Note

Only Adaxes service administrators have the rights to change the timeout for script execution.

In the script:

  • $serviceHost - the host name of the computer where the Adaxes service is installed.
  • $timeoutMin - the amount of time (in minutes) Adaxes will wait for a script or program to execute.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"
$timeoutMin = 15

# Connect to the Adaxes service.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the 'Configuration Set Settings' container.
$path = $admService.Backend.GetConfigurationContainerPath("ConfigurationSetSettings")
$settings = $admService.OpenObject($path, $credential.UserName,`
    $credential.GetNetworkCredential().Password, 0)

# Update the timeout.
$timeoutMs = [System.Convert]::ToInt32( `
    (New-TimeSpan -Minute $timeoutMin).TotalMilliseconds)
$settings.SetParameter("Adsi.ScriptExecutionTimeout", $timeoutMs)

View the current timeout

To view the current timeout, use the below script. In the script, the $serviceHost variable specifies the host name of the computer where the Adaxes service is installed.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost"

# Connect to the Adaxes service.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the 'Configuration Set Settings' container.
$path = $admService.Backend.GetConfigurationContainerPath("ConfigurationSetSettings")
$settings = $admService.OpenObject($path, $credential.UserName,`
    $credential.GetNetworkCredential().Password, 0)

# Output the timeout.
$timeoutSpan = `
    [System.TimeSpan]::FromMilliseconds($settings.GetParameter("Adsi.ScriptExecutionTimeout"))
Write-Host "Timeout for running PowerShell scripts and external programs is"`
     $timeoutSpan.Minutes "minutes"