DbUp setting command timeout in PowerShell (ExecutionTimeout)

I needed to increase the command timeout in DbUp from the default 30s to 10min and all examples that I found were in C#.

The good news is that PowerShell support of .net is really good and I manage to even use a callback function:


$dbUp = [DbUp.DeployChanges]::To
$dbUp = [SqlServerExtensions]::SqlDatabase($dbUp, $constr)
$dbUp = [StandardExtensions]::WithScriptsFromFileSystem($dbUp, $scriptPath)

$dbUp.Configure({ param($c); $c.ScriptExecutor.ExecutionTimeoutSeconds = 10 * 60 }) # 10 min command timeout

$dbUp = [StandardExtensions]::LogToConsole($dbUp)
$upgradeResult = $dbUp.Build().PerformUpgrade()

If you want to use DbUp for database maintenance script automation check here.

Reference article with C# timeout setting solution here.

DbUp setting command timeout in PowerShell (ExecutionTimeout)