Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure CLI SQL DB还原时间格式_Azure_Powershell_Azure Sql Database_Azure Cli - Fatal编程技术网

Azure CLI SQL DB还原时间格式

Azure CLI SQL DB还原时间格式,azure,powershell,azure-sql-database,azure-cli,Azure,Powershell,Azure Sql Database,Azure Cli,我正在使用Azure CLI编写一个Powershell脚本,用于执行Azure SQL实例还原。这是我目前的脚本: az login $AzureSubscription = "SubscriptionName" az account set --subscription $AzureSubscription $RGName = "ResourceGroupName" $SrvName = "AzureSQLServerName" $RestoreDateTime = (Get-Date

我正在使用Azure CLI编写一个Powershell脚本,用于执行Azure SQL实例还原。这是我目前的脚本:

az login

$AzureSubscription = "SubscriptionName"
az account set --subscription $AzureSubscription

$RGName = "ResourceGroupName"
$SrvName = "AzureSQLServerName"

$RestoreDateTime = (Get-Date).ToUniversalTime().AddHours(-1).ToString()
$RestoreDateTimeString = (Get-Date).ToUniversalTime().AddHours(-1).ToString("yyyy-MM-dd_HH:mm")
$RestoreName = $SrvName + "_" + $RestoreDateTimeString

az sql db restore --dest-name $RestoreName --resource-group $RGName --server $SrvName --name $SrvName  --time = $RestoreDateTime
当我运行此操作时,会出现以下错误:

az: error: unrecognized arguments: 7/10/2019 10:39:21 AM
usage: az [-h] [--verbose] [--debug]
          [--output {json,jsonc,table,tsv,yaml,none}] [--query JMESPATH]
          {sql} ...

我尝试过各种各样的日期时间格式,但是,我似乎无法让它们中的任何一种工作。是否需要特定的格式?我应该在时间中传递不同的值吗?任何帮助都将不胜感激。

据我所知,
--time
参数希望将日期时间格式化为“可排序的日期/时间模式”(yyyy-MM-ddTHH:MM:ss)

这应该做到:

$RestoreDateTime       = (Get-Date).ToUniversalTime().AddHours(-1)
$RestoreDateTimeString = '{0:yyyy-MM-dd_HH:mm}' -f $RestoreDateTime
$RestoreName           = '{0}_{1}' -f  $SrvName, $RestoreDateTimeString

# format the datetime as Sortable date/time pattern 'yyyy-MM-ddTHH:mm:ss'
# see: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
$azRestoreTime         = '{0:s}' -f $RestoreDateTime

az sql db restore --dest-name $RestoreName --resource-group $RGName --server $SrvName --name $SrvName  --time $azRestoreTime

希望这有助于解决我的问题。谢谢。我想ISO8601也应该能用。