Connect to PSB API with Powershell

I just got access to an API key and would like to pull some data from the PSB portal and compare with AD. Sadly I cannot figure out how to connect via Powershell.

Found this: https://community.f-secure.com/en/discussion/91901/conncet-to-api-via-powershell

where it seemed to be solved but the solutions isn't shown in the posts.

Can anyone point me in the right direction?

/Danny

Accepted Answer

Answers

  • jameschjamesch Posts: 255 Moderator

    Hi Danny

    The official help documents and Quick Start Guide can be found here. They contain the full documentation as well as examples of information requests.

  • PetriKuikkaPetriKuikka Posts: 215 F-Secure Employee

    Hi @DannyMalvang,

    did you get the problem sorted out? If not you can drop the calls you are trying to me in private message and I can check what is going wrong.

    Petri

    DannyMalvang
  • DannyMalvangDannyMalvang Posts: 10 New Member

    h41ryb4wb46

    I got it working with your help, but mostly I was using a - instead of a _ in the username. DOH! It helps if the credentials is correct


    Heres what I did:

    $url = "<API URL>"

    $apiKey = 'XXXXXXXXXXX'

    $auth = @{

     'X-API-Key' = $apiKey

    }

    $body = @{

     'username' = "[email protected]"

     'password' = "123456789"

    }

    $token = (invoke-restmethod -Uri "$url/authentication/login" -Method Post -Headers $auth -Body $body).token


    Now I can use wget to get all computers:


    wget -Uri "$url/partners/1234/reports/computers" -Method Get -Headers @{ 'x-api-key' = $apiKey ; Authorization = "Bearer $Token"}


    Now I only need to figure out how to reformat the data to something usefull

Sign In or Register to comment.