A playground project for exploring the MS Graph
To set up the CLI:
# If not already signed in with az:
az login
# Install CLI
python setup.py install
# Configure bash completion (add to .bashrc to auto-load in new shell sessions`)
source <(_GRAPHUTIL_COMPLETE=bash_source graphutil)
# Check installed
graphutil --helpMost commands support formatting output as table (default), json, jsonc, raw, or none via the --output option. This can also be controlled using the GRAPHUTIL_OUTPUT environment variable, i.e. set GRAPHUTIL_OUTPUT to table to default to the table output format.
| Option | Description |
|---|---|
table |
Works well for interactive use |
json |
Plain JSON output, ideal for parsing via jq or other tools |
jsonc |
Coloured, formatted JSON |
raw |
Results are output as-is. Useful with --query when capturing a single value |
none |
No output |
Most commands support JMESPath queries for the output via the --query option.
For example, to get a list of name of reports for someone@example.com run graphutil user reports someone@example.com --query [].name.
This can be combined with --output table, e.g. graphutil user reports someone@example.com -o table --query '[].{name:name, email:email}'. Note that the query result must be an object with named properties (or an array of such objects)
user is a command group for user-related commands.
To get a list of reports for a user:
graphutil user reports someone@example.comTo get a list of reports for a user in a specific region:
graphutil user reports someone@example.com --output table --query "[?contains(department, 'EMEA')]"To get a photo for a user:
grahputil user photo someone@example.com output_filename.jpgThis can be combined with other queries, e.g.
graphutil user reports someone@example.com --output json --query "[?contains(department, 'EMEA')] | [].upn" \
| jq -r ".[]"\
| xargs -I {} graphutil user photo {} {}.jpg