今天日期的最后一周数据 - 语法错误
Last one week data from today's date - syntax error
我正在尝试使用 powershell 脚本从 LTM 从今天的日期提取过去 7 天的数据。我没有插入具体的开始时间和结束时间,而是尝试自动执行此操作以获取从 7 天到今天的数据。到目前为止,我已经尝试过。
$Query = New-Object -TypeName iControl.SystemStatisticsPerformanceStatisticQuery
$Query.object_name = "throughput"
$Query.start_time = (get-date).AddDays(-7)
$Query.end_time = get-date
$Query.interval = 0
$Query.maximum_rows = 0
但我收到以下错误:
Exception setting "start_time": "Cannot convert value "2/22/2017 12:26:35 PM" to type "System.Int64". Error: "Invalid cast from 'DateTime' to 'Int64'.""
At line:1 char:1
+ $Query.start_time = (get-date).AddDays(-7)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
这应该有效:
$query.start_time = [int][double]::Parse((Get-Date -Date ((get-date).AddDays(-7)) -UFormat %s))
正如我在评论中所说,它期待 unixtimestamp,我们给了他。
我正在尝试使用 powershell 脚本从 LTM 从今天的日期提取过去 7 天的数据。我没有插入具体的开始时间和结束时间,而是尝试自动执行此操作以获取从 7 天到今天的数据。到目前为止,我已经尝试过。
$Query = New-Object -TypeName iControl.SystemStatisticsPerformanceStatisticQuery
$Query.object_name = "throughput"
$Query.start_time = (get-date).AddDays(-7)
$Query.end_time = get-date
$Query.interval = 0
$Query.maximum_rows = 0
但我收到以下错误:
Exception setting "start_time": "Cannot convert value "2/22/2017 12:26:35 PM" to type "System.Int64". Error: "Invalid cast from 'DateTime' to 'Int64'.""
At line:1 char:1
+ $Query.start_time = (get-date).AddDays(-7)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
这应该有效:
$query.start_time = [int][double]::Parse((Get-Date -Date ((get-date).AddDays(-7)) -UFormat %s))
正如我在评论中所说,它期待 unixtimestamp,我们给了他。