Skip to content

Instantly share code, notes, and snippets.

@btipling
Last active June 2, 2020 19:53
Show Gist options
  • Select an option

  • Save btipling/ee096da8b794deab6d621bf9b8ec41c4 to your computer and use it in GitHub Desktop.

Select an option

Save btipling/ee096da8b794deab6d621bf9b8ec41c4 to your computer and use it in GitHub Desktop.

Revisions

  1. btipling revised this gist Jun 2, 2020. 2 changed files with 28 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions output.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    PS C:\Users\swart\projects\powershell_scripts> .\get_remote_data.ps1

    PS C:\Users\swart\projects\powershell_scripts> Find-RemoteData -Name "bar"

    10
    PS C:\Users\swart\projects\powershell_scripts> Find-RemoteData -Name "foo"

    3
    PS C:\Users\swart\projects\powershell_scripts> (Find-RemoteData -Name "bar") + (Find-RemoteData -Name "foo")

    13
    PS C:\Users\swart\projects\powershell_scripts> Read-RemoteData


    foo bar
    --- ---
    3 10
    11 changes: 11 additions & 0 deletions remote_data.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    $global:dataURL = "https://gist.github.com/btipling/ee096da8b794deab6d621bf9b8ec41c4/raw/d46f89efa3059c1e3915dafe5b438f4e41bcf859/foo.json"

    function global:Read-RemoteData() {
    Invoke-RestMethod -Uri $global:dataURL
    }

    function global:Find-RemoteData([string]$Name) {
    $response = Invoke-WebRequest -Uri $global:dataURL
    $data = $response.Content | ConvertFrom-Json -AsHashtable
    [int] $data[$Name]
    }
  2. btipling revised this gist Jun 2, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions foo.json
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    {
    "name": "foo",
    "value": 2
    "foo": 3,
    "bar": 10
    }
  3. btipling created this gist Jun 2, 2020.
    4 changes: 4 additions & 0 deletions foo.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    {
    "name": "foo",
    "value": 2
    }