Public/Curanet/Get-CuranetCustomer.ps1

function Get-CuranetCustomer() {
    Param(
        [Parameter()]
        [string]$CustomerName
    )


    # Get a Curanet 3850 API access token
    $AccessToken = Get-AccessToken

    $AuthorizationHeader = @{
        Authorization="Bearer $AccessToken"
    }

    try {
        $Customers = (Invoke-WebRequest -Uri "https://api.curanet.dk/customers/v1/Customers?itemsPerPage=9999" -Headers $AuthorizationHeader -UseBasicParsing -Method GET).Content | ConvertFrom-Json
    } catch {
        Write-Error "Failed to retreive customers from Curanet 3850 API: $_"
    }

    if($CustomerName) {
        $Customers | Where-Object { $_.companyName -eq $CustomerName }
    }
    return $Customers
}