Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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
使用powershell调用https api调用_Powershell - Fatal编程技术网

使用powershell调用https api调用

使用powershell调用https api调用,powershell,Powershell,有人可以帮助您获取开始时间、结束时间、持续时间,并使用powershell脚本执行API吗 范例 需要执行以下示例API 获取格式为“2021-05-22T12:15:27.000027”的当前UTC时间并存储在此变量中 StartTimeInUTC=2021-05-22T12:15:27.000027 在API下面调用 https:test.com/${StartTimeInUTC}下面的代码显示了如何在powershell中调用API $StartTimeInUTC = Get-Date -

有人可以帮助您获取开始时间、结束时间、持续时间,并使用powershell脚本执行API吗

范例 需要执行以下示例API

获取格式为“2021-05-22T12:15:27.000027”的当前UTC时间并存储在此变量中

StartTimeInUTC=2021-05-22T12:15:27.000027 在API下面调用


https:test.com/${StartTimeInUTC}

下面的代码显示了如何在powershell中调用API

$StartTimeInUTC = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." }
Write-Host $StartTimeInUTC
$url = "https://test.com/${StartTimeInUTC}"

Write-Host $url

$webrequest = Invoke-WebRequest -Uri $url -SessionVariable websession  -UseBasicParsing


$EndTimeInUTC = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." }

Write-Host $EndTimeInUTC