Powershell and Rest API integration - Customer ID param is Mandatory for MSP

Powershell and Rest API integration - Customer ID param is Mandatory for MSP

Good day all

I have been working for quite some time with Powershell, but have very limited knowledge of using Powershell with APIs. 

I would like to make use of Powershell to connect to our local installation of Manage Engine Desktop Central and to pull certain reports from time to time.

Through some of the forums here, I have managed to connect to our instance via Powershell, but is getting an error:

Customer ID param is Mandatory for MSP

when I try to get RemoteOffice information. I get the same error on any of the other get calls.

My code is:
#Credentials
$username   = "MyUsername"
$password   = "MyPassword"
$bytes      = [System.Text.Encoding]::ASCII.GetBytes($password)
$password64 = [Convert]::ToBase64String($bytes)

#Authentication parameters
$authurl    = 'https://MyManageEngineInstance:port/api/1.3/desktop/authentication'
$authbody   = @{username = $username; password = "$password64"; auth_type = 'local_authentication'}

#Authentication
$request    = Invoke-RestMethod -Method GET -Uri $authurl -Body $authbody 
$Auth_Token = $Request.message_response.authentication.auth_data.auth_token
return $request

#Header required for all API requests using received token
$apiheader  = @{Authorization=$Auth_Token;}

#Sample request for data
$url = 'https://MyManageEngineInstance:port/api/1.3/som/remoteoffice'

$RemoteOfficeData = Invoke-RestMethod -Method GET -Uri $url -Headers $apiheader
$RemoteOfficeData

The error is (The failure occurs on the last Invoke-RestMethod call - All other calls are successful)

error_description : Customer ID param is Mandatory for MSP
message_type      : remoteoffice
error_code        : 1008
message_version   : 1.3
status            : error




My Questions are:

1. Where do I get the Customer ID from? (We are configured as the only Customer on our server).
2. How should change this line ($RemoteOfficeData = Invoke-RestMethod -Method GET -Uri $url -Headers $apiheader), to include the Customer ID.
3. Can I use Powershell to display all customer IDs via the REST APIs?

Thanks for your advice in advance.

E.

                New to ADManager Plus?

                  New to ADSelfService Plus?