API Call via power shell to send script

F
fabrice.dodorico
OFFICE DEPOT FR

You have post this script :

$MCUsername = "MobiControl username goes here"
$MCPassword = "MobiControl Password goes here"
$MCFQDN = "MobiControl FQDN Goes here"
$ClientID = "MobiControl API Client ID Goes here"
$ClientSecret = "MobiControl Client Secret Goes here"
# You may want to figure out a way to encrypt the Password and the Secret, that's best practice

$IDSecret = $ClientID + ":" + $ClientSecret 
$EncodedIDSecret = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($IDSecret))

$Body = @{}
$Body["grant_type"]="password"
$Body["username"]=$MCUsername
$Body["password"]=$MCPassword

$Header = @{}
$Header["Authorization"] = "Basic " + $EncodedIDSecret

try
{
$response = Invoke-restmethod -Uri  https://$MCFQDN/mobicontrol/api/token -Method POST -Headers $Header -Body $Body
}
catch
{
$($_.Exception.Message)
}

$Token = $response.access_token

Write-Host "My MobiControl API Token is: $Token"

#Now you can use the Token in other API calls by refering to the Token Variable.


I want to send this script via the console script below via the powershell api call:

sendintent -a "intent:file:///sdcard/clochecausses.mp3#Intent;type=audio;component=com.android.music;end"

Can you add an exemple please ?

In this script where to find client ID and client secret in the web console ( it is the name of the device ?, client secret is pin code ? )

Thanks a lot.

Edited 6 years ago
Android
ANSWERS
SB
Simon Breuer
6 years ago

Hi!

You need to generate ClientID and ClientSecret as follows:

- Open CMD on Management Server

- Move to directory C:\Program Files\SOTI\MobiControl

- Type MCAdmin.exe APIClientAdd -n:[ANY_NAME_YOU_WANT]

- ID and Secret are being displayed. Use them in the script. At this moment a database entry was generated so MobiControl allows this user to use API calls.

Unfortunately I don't know the syntax to send the sendintent script via API. May be sombody else might help you.

F
fabrice.dodorico
6 years ago

Thanks a lot,

I do the create api procedure

The script works perfectly, i am able to send message with an API call.

But for the moment i am not able to make this call via api:

sendintent -a "intent:file:///sdcard/clochecausses.mp3#Intent;type=audio;component=com.android.music;end"

{
"Action": "SendScript",
"Message": "devrename newname"
}

for me

{
"Action": "SendScript",
"Message": "sendintent -a "intent:file:///sdcard/clochecausses.mp3#Intent;type=audio;component=com.android.music;end""
}

I think my problem is caused by the url formatter

Is someone can help.