It is said that imitation is the sincerest form of flattery and if you are familiar with the Azure CLI, you can tell we are fans. The Microsoft Graph CLI leverages the same tool chain that is used to build the Azure CLI, but instead brings the entire surface area of Microsoft Graph to your command shell.
This project is still in its early phases, but we are building not only on the work of the Azure CLI team but also on the Microsoft Graph PowerShell SDK project to enable us to quickly generate a CLI for all the new capabilities of Microsoft Graph as soon as they are available.
Windows
Download the .msi package from the latest release
Linux
If you're using Ubuntu 20.04+, download and install libffi6
sudo apt install path/to/libff6
Download the .deb package from the latest release and install the package with the command below.
sudo dpkg -i msgraph-cli_all.deb
Docker
Build a docker image by running the command below.
docker build --target build-env -f ./build_scripts/debian/Dockerfile -t microsoft/msgraph-cli:ubuntu-builder .
Run the docker container interactively using the command below.
docker run -it --name deb microsoft/msgraph-cli:ubuntu-builder
$ mg [ group ] [ command ] {parameters}
$ mg login --scopes "user.read.all"
You can use the --query
parameter and the JMESPath query syntax to customize your output.
$ mg users list-user --query "[?userType=='Member'].{name: displayName, email: mail}" --output table
Name Email
------------------------ -------------------------------------
Conf Room Adams Adams@M365x555627.OnMicrosoft.com
Adele Vance AdeleV@M365x555627.OnMicrosoft.com
MOD Administrator admin@M365x555627.OnMicrosoft.com
Alex Wilber AlexW@M365x555627.OnMicrosoft.com
For scripting purposes, we output certain exit codes for differing scenarios.
Exit Code | Scenario |
---|---|
0 | Command ran successfully. |
1 | Generic error; server returned bad status code, CLI validation failed, etc. |
2 | Parser error; check input to command line. |
If you encounter any bugs with the tool please file an issue in the Issues section of our GitHub repo.
To provide feedback from the command line, try the az feedback
command.
If you would like to setup a development environment and contribute to the CLI, see:
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.