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

Best Answer

Answers

  • JamesC
    JamesC W/ Partner, W/ Staff, W/ Moderator Posts: 498 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.

  • PetriKuikka
    PetriKuikka W/ Member Posts: 236 Threat Terminator

    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
    DannyMalvang W/ Alumni Posts: 10 Security Scout

    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' = "asdsa@dsads.com"

     '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

This discussion has been closed.