Script that will generate a list of all users who have voice contacts.

XMLWordPrintable

    • 1

      Issue Summary

      (no)
      From the description - Users that don't know how to start/run PowerShell scripts, as this is not an Opsgenie support task, can escalate internally to a systems admin who has these skills. I am reaching for an FR suggestion here since the escalation engineer suggested it.

      Steps to Reproduce

      1. The logic they should construct should use our user API in combination with our contacts API.
        They will need to change the baseUrl and GenieKey:
        $contactType = "voice"
        $baseURL = "https://api.eu.opsgenie.com"
        
        [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
        $headers = @{Authorization='GenieKey x1x1x1x1x-x1x1x1-x1x1x1x-x1x1x1-x1x1x1x1'}
        
        Echo "username,phoneNumber,enabled" > contacts.csv
        
        (Invoke-RestMethod -Method get -Uri "$($baseURL)/v2/users" -ContentType "application/json" -Headers $headers).data | foreach {
        $username = $_.username
        $phoneNumber = ""
        #echo $username
        (Invoke-RestMethod -Method get -Uri "$($baseURL)/v2/users/$($username)/contacts" -ContentType "application/json" -Headers $headers).data | where {$_.method -match $contactType} | foreach {
        $phoneNumber = $_.to
        echo "$($username),$($phoneNumber),$($_.status.enabled)" >> contacts.csv
        }
        }
        
        import-csv contacts.csv

      Expected Results

       

      The expected outcome of this is that the user will be able to use the provided PowerShell script as an example to reference when writing their own script to generate a list of all users who have voice contacts. The user will need to change the baseUrl and GenieKey in the script and will also need to have the necessary skills to run PowerShell scripts. 

      Actual Results

      Not able to extract the information needed or reaching a point where they don't know how to create a PowerShell.

      ...
      

      Workaround

      They will need to change the baseUrl and GenieKey:

      $contactType = "voice"
      $baseURL = "https://api.eu.opsgenie.com"
      
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      $headers = @{Authorization='GenieKey x1x1x1x1x-x1x1x1-x1x1x1x-x1x1x1-x1x1x1x1'}
      
      Echo "username,phoneNumber,enabled" > contacts.csv
      
      (Invoke-RestMethod -Method get -Uri "$($baseURL)/v2/users" -ContentType "application/json" -Headers $headers).data | foreach {
      $username = $_.username
      $phoneNumber = ""
      #echo $username
      (Invoke-RestMethod -Method get -Uri "$($baseURL)/v2/users/$($username)/contacts" -ContentType "application/json" -Headers $headers).data | where {$_.method -match $contactType} | foreach {
      $phoneNumber = $_.to
      echo "$($username),$($phoneNumber),$($_.status.enabled)" >> contacts.csv
      }
      }
      
      import-csv contacts.csv
      

            Assignee:
            Unassigned
            Reporter:
            Rafael Meira (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: