mog — Microsoft Ops Gadget
CLI for Microsoft 365: Mail, Calendar, OneDrive, Contacts, Tasks, Word, PowerPoint, Excel, OneNote.
The Microsoft counterpart to gog (Google Ops Gadget). Same patterns, different cloud.
Quick Reference
For comprehensive usage, run:
mog --ai-help
This outputs the full dashdash-compliant documentation including:
- Setup/Prerequisites
- All commands and options
- Date/time formats
- Examples (positive and negative)
- Troubleshooting
- Slug system explanation
- gog compatibility notes
Modules
| Module |
Commands |
| mail |
search, get, send, folders, drafts, attachment |
| calendar |
list, create, get, update, delete, calendars, respond, freebusy, acl |
| drive |
ls, search, download, upload, mkdir, move, rename, copy, rm |
| contacts |
list, search, get, create, update, delete, directory |
| tasks |
lists, list, add, done, undo, delete, clear |
| word |
list, export, copy |
| ppt |
list, export, copy |
| excel |
list, get, update, append, create, metadata, tables, add-sheet, clear, copy, export |
| onenote |
notebooks, sections, pages, get, create-notebook, create-section, create-page, delete, search |
Quick Start
# Mail
mog mail search "from:someone" --max 10
mog mail send --to a@b.com --subject "Hi" --body "Hello"
mog mail send --to a@b.com --subject "Report" --body-file report.md
mog mail send --to a@b.com --subject "Newsletter" --body-html "<h1>Hello</h1>"
cat draft.txt | mog mail send --to a@b.com --subject "Hi" --body-file -
# Calendar
mog calendar list
mog calendar create --summary "Meeting" --from 2025-01-15T10:00:00 --to 2025-01-15T11:00:00
mog calendar freebusy alice@example.com bob@example.com
# Drive
mog drive ls
mog drive upload ./file.pdf
mog drive download <slug> --out ./file.pdf
# Tasks
mog tasks list
mog tasks add "Buy milk" --due tomorrow
mog tasks clear
# Contacts
mog contacts list
mog contacts directory "john"
# Excel
mog excel list
mog excel get <id> Sheet1 A1:D10
mog excel update <id> Sheet1 A1:B2 val1 val2 val3 val4
mog excel append <id> TableName col1 col2 col3
# OneNote
mog onenote notebooks
mog onenote search "meeting notes"
Slugs
mog generates 8-character slugs for Microsoft's long GUIDs:
a3f2c891 instead of AQMkADAwATMzAGZmAS04MDViLTRiNzgt...
- All commands accept slugs or full IDs
- Use
--verbose to see full IDs
Command Aliases
mog cal → mog calendar
mog todo → mog tasks
Named Aliases
Create memorable @names for frequently-used IDs:
mog alias set @standup f1a2b3c4
mog calendar get @standup
mog alias list
mog alias rm @standup
@ prefix, shell-safe
- Chain resolution:
@alias → slug → full ID
- Stored per-account in
~/.config/mog/{account}/aliases.json
Multi-Account Support
Manage multiple Microsoft 365 accounts (personal, work, etc.):
# Setup additional accounts
mog auth login --client-id YOUR_CLIENT_ID --account work
mog auth login --client-id YOUR_CLIENT_ID --account personal
# Use specific account
mog mail search "*" --account work
mog calendar list --account personal
# Or set via environment variable
export MOG_ACCOUNT=work
mog mail search "*"
# List configured accounts
mog auth list
Credential Storage
OAuth tokens stored in config directory (0600 permissions):
| Platform |
Location |
| macOS |
~/.config/mog/{account}/ |
| Linux |
~/.config/mog/{account}/ |
| Windows |
%USERPROFILE%\.config\mog\{account}\ |
Files per account:
tokens.json - OAuth tokens
settings.json - Client ID
slugs.json - Slug cache
Default account is default. Existing single-account setups auto-migrate.
See Also
mog --ai-help - Full documentation
mog <command> --help - Command-specific help
1---2name: mog3description: Microsoft Ops Gadget — CLI for Microsoft 365 (Mail, Calendar, Drive, Contacts, Tasks, Word, PowerPoint, Excel, OneNote).4---56# mog — Microsoft Ops Gadget78CLI for Microsoft 365: Mail, Calendar, OneDrive, Contacts, Tasks, Word, PowerPoint, Excel, OneNote.910The Microsoft counterpart to `gog` (Google Ops Gadget). Same patterns, different cloud.1112## Quick Reference1314For comprehensive usage, run:15```bash16mog --ai-help17```1819This outputs the full dashdash-compliant documentation including:20- Setup/Prerequisites21- All commands and options22- Date/time formats23- Examples (positive and negative)24- Troubleshooting25- Slug system explanation26- gog compatibility notes2728## Modules2930| Module | Commands |31|--------|----------|32| **mail** | search, get, send, folders, drafts, attachment |33| **calendar** | list, create, get, update, delete, calendars, respond, freebusy, acl |34| **drive** | ls, search, download, upload, mkdir, move, rename, copy, rm |35| **contacts** | list, search, get, create, update, delete, directory |36| **tasks** | lists, list, add, done, undo, delete, clear |37| **word** | list, export, copy |38| **ppt** | list, export, copy |39| **excel** | list, get, update, append, create, metadata, tables, add-sheet, clear, copy, export |40| **onenote** | notebooks, sections, pages, get, create-notebook, create-section, create-page, delete, search |4142## Quick Start4344```bash45# Mail46mog mail search "from:someone" --max 1047mog mail send --to a@b.com --subject "Hi" --body "Hello"48mog mail send --to a@b.com --subject "Report" --body-file report.md49mog mail send --to a@b.com --subject "Newsletter" --body-html "<h1>Hello</h1>"50cat draft.txt | mog mail send --to a@b.com --subject "Hi" --body-file -5152# Calendar53mog calendar list54mog calendar create --summary "Meeting" --from 2025-01-15T10:00:00 --to 2025-01-15T11:00:0055mog calendar freebusy alice@example.com bob@example.com5657# Drive58mog drive ls59mog drive upload ./file.pdf60mog drive download <slug> --out ./file.pdf6162# Tasks63mog tasks list64mog tasks add "Buy milk" --due tomorrow65mog tasks clear6667# Contacts68mog contacts list69mog contacts directory "john"7071# Excel72mog excel list73mog excel get <id> Sheet1 A1:D1074mog excel update <id> Sheet1 A1:B2 val1 val2 val3 val475mog excel append <id> TableName col1 col2 col37677# OneNote78mog onenote notebooks79mog onenote search "meeting notes"80```8182## Slugs8384mog generates 8-character slugs for Microsoft's long GUIDs:85- `a3f2c891` instead of `AQMkADAwATMzAGZmAS04MDViLTRiNzgt...`86- All commands accept slugs or full IDs87- Use `--verbose` to see full IDs8889## Command Aliases9091- `mog cal` → `mog calendar`92- `mog todo` → `mog tasks`9394## Named Aliases9596Create memorable `@names` for frequently-used IDs:9798```bash99mog alias set @standup f1a2b3c4100mog calendar get @standup101mog alias list102mog alias rm @standup103```104105- `@` prefix, shell-safe106- Chain resolution: `@alias` → slug → full ID107- Stored per-account in `~/.config/mog/{account}/aliases.json`108109## Multi-Account Support110111Manage multiple Microsoft 365 accounts (personal, work, etc.):112113```bash114# Setup additional accounts115mog auth login --client-id YOUR_CLIENT_ID --account work116mog auth login --client-id YOUR_CLIENT_ID --account personal117118# Use specific account119mog mail search "*" --account work120mog calendar list --account personal121122# Or set via environment variable123export MOG_ACCOUNT=work124mog mail search "*"125126# List configured accounts127mog auth list128```129130## Credential Storage131132OAuth tokens stored in config directory (0600 permissions):133134| Platform | Location |135|----------|----------|136| **macOS** | `~/.config/mog/{account}/` |137| **Linux** | `~/.config/mog/{account}/` |138| **Windows** | `%USERPROFILE%\.config\mog\{account}\` |139140Files per account:141- `tokens.json` - OAuth tokens142- `settings.json` - Client ID143- `slugs.json` - Slug cache144145Default account is `default`. Existing single-account setups auto-migrate.146147## See Also148149- `mog --ai-help` - Full documentation150- `mog <command> --help` - Command-specific help