-
Notifications
You must be signed in to change notification settings - Fork 0
/
IBTrades2OneDrive_AzFunction.ps1
36 lines (30 loc) · 1.1 KB
/
IBTrades2OneDrive_AzFunction.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Write-Output "PowerShell Timer trigger function executed at:$(get-date)";
$token = "000000000000000000000000"
$q = "123456"
$request = "https://gdcdyn.interactivebrokers.com/Universal/servlet/FlexStatementService.SendRequest?t=$token&q=$q&v=3"
$response = Invoke-WebRequest $request -UseBasicParsing
if ($response.StatusCode -ne '200')
{
Write-Verbose "Status code not 200-OK" 4>&1
$response.StatusCode
$response.StatusDescription
}
else
{
[xml]$xml = $response.Content
[string]$refCode = $xml.ChildNodes.ReferenceCode
[string]$flexUrl = $xml.ChildNodes.Url
$reqData = $flexUrl + "?q=$refCode&t=$token&v=3"
$responseData = Invoke-WebRequest $reqData -UseBasicParsing
if ($responseData.StatusCode -ne '200')
{
Write-Verbose "Status code not 200-OK" 4>&1
$response.StatusCode
$response.StatusDescription
}
else
{
$content = $responseData.Content
}
}
Out-File -Encoding ASCII -FilePath $outputFile -inputObject $content