Powershell 尝试向SEPM API提交GET请求时请求错误

Powershell 尝试向SEPM API提交GET请求时请求错误,powershell,symantec,Powershell,Symantec,我正试图向SEPM API提交一个请求,特别是使用赛门铁克提供的文档,但每当我尝试运行查询时,我都会收到(400)错误请求,老实说,我没有看到请求上的异常。这是我目前使用的代码: #Report type: Hour, Day, Week or Month $reportType = "Hour" #Get system time $startTime = Get-Date (Get-Date).AddHours(-1) $endTime = Get-Date #Con

我正试图向SEPM API提交一个请求,特别是使用赛门铁克提供的文档,但每当我尝试运行查询时,我都会收到
(400)错误请求
,老实说,我没有看到请求上的异常。这是我目前使用的代码:

#Report type: Hour, Day, Week or Month
$reportType = "Hour"

#Get system time
$startTime = Get-Date (Get-Date).AddHours(-1)
$endTime =  Get-Date

#Convert time to Epoch
$startTimeEpoch = Get-Date ($startTime).ToUniversalTime() -UFormat %s
$endTimeEpoch = Get-Date ($endTime).ToUniversalTime() -UFormat %s

$header = @{
    "Content-Type" = "application/json"
    "Authorization"= "Bearer $authToken"
}

$response = Invoke-RestMethod `
    -Uri "https://example:8446/sepm/api/v1/stats/client/malware/$reportType/$startTimeEpoch/to/$endTimeEpoch" `
    -Method GET `
    -Headers $header
Uri扩展如下
“https://example:8446/sepm/api/v1/stats/client/malware/Hour/1592937124.87678/to/1592940724.8778“

说明
{startTime}
{endTime}
在给定语法模式中都应该是整数(
int64
)。不幸的是,
-UFormat%s
将自1970年1月1日00:00:00以来经过的秒数作为双倍值返回。应用适当的转换,例如,如下所示:

$reportType = "Hour"

#Get system time
$endTime   = Get-Date
$startTime = $endTime.AddHours(-1)

#Convert time to Epoch
$startTimeEpoch = (Get-Date ($startTime).ToUniversalTime() -UFormat %s).
                    ToDouble([cultureinfo]::CurrentCulture) -as [int64]
$endTimeEpoch   = (Get-Date (  $endTime).ToUniversalTime() -UFormat %s).
                    ToDouble([cultureinfo]::CurrentCulture) -as [int64]
请注意,您可以简化代码,并记住以下两个表达式的计算结果均为true:


我完全错过了那个细节,我已经更改了代码,现在我可以从API获得响应。
$startTimeEpoch -eq $endTimeEpoch -3600
$startTimeEpoch +3600 -eq $endTimeEpoch