M5cmd REST API command line utility The REST API from Moka5 provides a programmatic way to perform certain tasks.
The API is flexible but will require scripting and customization.
M5cmd allows the use of the REST API as a command line utility with “assembly not required”.
Download m5cmd-v1.0.zipUnzip the package into any location and run.
The “m5runas.exe” and “djoin.exe” are used for creating Domain Join Packets.
These are the current commands available from the Moka5 REST API, and they are all available from within the command line utility.
Refer to the documentation
Using REST APIs in Moka5 for more information about the commands.
Syntax of the command line utility.
Type the command line utility without any parameters will show the usage syntax.
Examples showing the use of different commands, or known in REST API as resource URLs.
Note that the output format defaults to JSON, which is the native output from the REST API. The other formats are converted for potentially easier consumption by different systems.
Example of commands to retrieve information about a particular user.
It is possible to extract only specific attributes from the output for easier input into another system. Another option is available to output the values without the names of the keys.
To download the Client Installers, first find the versions available from the Moka5 Management Console. Use the version number as part of the command to download.
User subscriptions and devices can be Revoked, Unrevoked or Killed.
Note that the Killed command cannot be reversed, hence the extra acknowledgement in the command utility to ensure that the command is issued with full knowledge of its effect.
In general, the REST API requires a 2-step process to perform these commands. Firstly to retrieve the IDs of the subscriptions or devices that needs to be targeted.
The example below shows the use a batch file to automate these 2 commands into a single script. If a user has more than one subscriptions or devices, all of them will be targeted for convenience.
The following example runs the revoke.cmd script against user Mark in the Clifville domain. Note that Mark has 3 devices and all have been revoked.
2 parameters are required, namely the domain and user name.
The purpose of creating Domain Join Packets is to make it possible to join Moka5 LivePCs to a domain in locations where there is no connectivity to the corporate network.
This concept of “offline domain join” is described in this technical note from Microsoft using the “Djoin.exe” utility.
Offline Domain Join (Djoin.exe) Step-by-Step Guide There are 2 high level steps in creating Domain Join Packets automatically using APIs in Moka5. The M5cmd program automates these 2 steps.
-
Run the “djoin.exe” utility to generate a provision data file.
-
Use the Moka5 REST API to upload the provision data file unto the Moka5 Server. These DJPs can then be claimed by a LivePC.
First, find the LivePC ID for which the Domain Join Packet is going to be create for.
-
Method 1 – The LivePC ID can be found on the Moka5 Server in the following directory:
C:\Program Files\MokaFive\m5fs\master-1
The folder names are the LivePC IDs, for example: huffcorp-b50ebef2e16f43b28494184ebc38f8f2
-
Method 2 – The LivePC ID can also be found on a client host machine in the following directory on Windows
C:\Users\<username>\AppData\Local\mokafive\livepcs
The name of the folder within the directory contains the LivePC ID
-
Method 3 – If there are already Domain Join Packets previously created, the M5cmd utility using the following command will also list all the Domain Join Packets available
--command=/api/adpackets
This is a simplest command with all the required parameters to generate the Domain Join Packet using a LivePC ID.
This example creates and reserves a Domain Join Packet for user mark. The resulting Domain Join Packet is also shown in the Moka5 management console after being created.
-
Slow response from m5cmd
If the utility seems slow, it might be because it is trying to automatically detect network configuration due the API used.
Try turning Automatic off by doing the following:
-
Control Panel à Internet Options à Connections tab à LAN settings button
-
Uncheck Automatically detect settings option