Initialize-CoinbaseModule.ps1
Try { Write-Progress -Activity 'Coinbase Module' -Status 'Updating data...' If ((Test-Path -Path "$env:ALLUSERSPROFILE\Coinbase") -eq $False) { New-Item -Path "$env:ALLUSERSPROFILE\Coinbase" -ItemType Directory -Force | Out-Null ICACLS "$env:ALLUSERSPROFILE\Coinbase\" /Grant:R 'Everyone:(OI)(CI)(F)' /Q /C /T | Out-Null } $Headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]' $Headers.Add('Content-Type', 'application/json') $Result = Invoke-RestMethod 'https://api.exchange.coinbase.com/currencies' -Method 'GET' -Headers $Headers $Currency = $Result | Select-Object Id | Sort-Object Id | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1 $Currency = $Currency.Replace("""", "") $Currency | Out-File -FilePath "$env:ALLUSERSPROFILE\Coinbase\Currencies.txt" -Force $Response = Invoke-RestMethod 'https://api.exchange.coinbase.com/products' -Method 'GET' -Headers $Headers $Pair = $Response | Select-Object Id | Sort-Object Id | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1 $Pair = $Pair.Replace("""", '') $Pair | Out-File -FilePath "$env:ALLUSERSPROFILE\Coinbase\Pairs.txt" -Force } Catch { Write-Warning -Message "Updating Coinbase data failed: $($PSItem.Exception.Message)" } |