【发布时间】:2018-09-18 23:35:39
【问题描述】:
我在 Azure 上运行手册的 powershell 脚本中遇到错误:
Write-Error : A positional parameter cannot be found that accepts argument '+'.
At Test-Update-IndexesForallShardsFromShardManagerRunbook:61 char:61
+
+ CategoryInfo : InvalidArgument: (:) [Write-Error], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteErrorCommand
根据我在 Azure autmation 帐户上看到的运行作业的日志,我在以下代码中的某处查明了脚本中错误的根源:
$updateStatisticSql = "UPDATE STATISTICS [$Using:tableName] ( [$Using:statName] );"
$CmdUpdateStats=new-object system.Data.SqlClient.SqlCommand($updateStatisticSql, $Conn1)
$CmdUpdateStats.CommandTimeout=1500
Try
{
$Ds=New-Object system.Data.DataSet
$Da=New-Object system.Data.SqlClient.SqlDataAdapter($CmdUpdateStats)
[void]$Da.fill($Ds)
}
Catch
{
# Will catch the exception here so other statistics can be processed.
Write-Error "Statistic " + $tableName + "(" + $statName + ") could not be updated. Investigate the statistic."
}
似乎在每行之后添加日志记录后,它不会在“填充”函数之后记录,所以我认为那里出了问题。但我没有看到错误与此功能之间的关系。它似乎也不是脚本中断错误,因为它永远不会进入捕获状态,并且其余脚本运行良好。即使出现错误,我也验证了统计信息已更新。
【问题讨论】:
标签: powershell azure azure-sql-database azure-automation