You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Microsoft Graph CLI SDK provides convenient methods to access Microsoft Graph capabilities using a simplistic command line interface experience on any operating system and any shell.
3
+
Microsoft Graph CLI SDK provides convenient methods to access Microsoft Graph capabilities using a simplistic command line interface experience on any operating system and any shell.
4
4
5
5
## Required tools
6
6
A commandline tool should work on any terminal. We recommend:
Windows, Mac, or Linux here on the assets link of the latest release: [CLI SDK Download](https://github.com/microsoftgraph/msgraph-cli/releases)
14
14
15
15
16
+
### Windows
17
+
1. Extract downloaded CLI tool for Windows to folder
18
+
2. Execute program using **mgc** (on Windows CMD) or **./mgc** (on Windows PowerShell) command.
19
+
20
+
21
+
#### Windows environment setup (Optional)
22
+
23
+
To allow executing the mgc command without prefixing it with `./`, you can add the executable's directory to the OS Path environment variable.
24
+
On Windows PowerShell, you can add the current directory to the path by running:
25
+
26
+
```powershell
27
+
$env:Path += ";$(pwd)`
28
+
```
29
+
30
+
On CMD, the command becomes:
31
+
```cmd
32
+
set PATH=%PATH%;%cd%
33
+
```
34
+
35
+
Though adding the current directory to the path doesn't change how you run mgc on CMD, it allows you to switch the directory you're working in.
36
+
This is useful for when you need to use a different directory to save files downloaded from the CLI.
37
+
38
+
The commands above will update your Path for the current command session, and will need to be run whenever you start a new session e.g. when opening a new window.
39
+
To make the changes permanent, you can update the environment variables by using the **System properties** dialog.
40
+
You can find it by either using windows search (it appears as _view advanced system settings_) in the start menu, or following the steps below:
41
+
42
+
1. Open the **Settings** app
43
+
2. Click on **System**
44
+
3. Select the **About** option. It should be the last one in the list.
45
+
4. In the **About** screen, locate and click on the _Advanced system settings_ link in the **Related links** section just below the device specifications.
46
+
5. Once the dialog is open, click on the **Environment Variables** button on the bottom right.
47
+
6. Select the Path environment variable and click **Edit**.
48
+
7. Add the directory with the CLI to the path here.
49
+
50
+
> The Environment Variables screen should have 2 sections that both have a Path entry. The _User variables_ section adds to the current user's path and other users' environments should remain unchanged. The _System variables_ section will make the changes for all users in the computer.
51
+
52
+
53
+
### MacOS
54
+
55
+
1. Download the CLI archive for your Mac.
56
+
- If you have an M1 Mac computer, download the `msgraph-cli-osx-arm64...` package.
57
+
- If you have an Intel processor, download the `msgraph-cli-osx-x64...` package.
58
+
2. Extract downloaded CLI tool for Mac to a folder.
59
+
3. Open a terminal in the new folder
60
+
4. Execute the program using **./mgc** command.
61
+
62
+
#### Mac environment setup (Optional)
63
+
64
+
If you'd like to run the CLI from any folder, you need to either update the PATH environment variable for your shell,
65
+
or add a symbolic link to the CLI into a location in the PATH (e.g. /usr/bin). Adding a symbolic link will need
66
+
super user rights depending on the location you choose.
67
+
68
+
Adding to the PATH for your current session is also an option as it is in Windows. To do this, run the following command
69
+
from your terminal in the directory of the CLI:
70
+
71
+
```sh
72
+
export PATH=$PATH:$(PWD)
73
+
```
74
+
75
+
Adding the location permanently can be done for the current user by editing your `~/.bash-profile` file.
76
+
Add the following line to your profile:
77
+
78
+
```sh
79
+
export PATH=$PATH:[path-to-the-cli-folder]
80
+
```
81
+
82
+
Adding a symbolic link into `/usr/bin` (not recommended) can be done with the command below:
83
+
84
+
```sh
85
+
sudo ln -s [path-to-the-cli-folder]/mgc /usr/bin
86
+
```
87
+
88
+
89
+
### Linux
90
+
91
+
Download from browser OR via Curl
92
+
93
+
```bash
94
+
curl -LO <link>&& tar -xzf <filename>
95
+
```
96
+
97
+
#### Linux environment setup (Required)
98
+
99
+
The linux environment setup is similar to the Mac setup, but with one difference. For headless linux environments,
100
+
there's an additional step to configure the keyring for access token encryption.
101
+
102
+
To set up the PATH environment variable for your current session, run the following command from your terminal
103
+
in the directory of the CLI:
104
+
105
+
```sh
106
+
export PATH=$PATH:$(PWD)
107
+
```
108
+
109
+
Adding the location permanently can be done for the current user by editing your shell's profile file
110
+
(`~/.bash-profile` or `~/.zsh-profile`) file. Add the following line to your profile:
111
+
112
+
```sh
113
+
export PATH=$PATH:[path-to-the-cli-folder]
114
+
```
115
+
116
+
Adding a symbolic link into `/usr/bin` (not recommended) can be done with the command below:
117
+
118
+
```sh
119
+
sudo ln -s [path-to-the-cli-folder]/mgc /usr/bin
120
+
```
121
+
122
+
123
+
>**Note:** The following step is **Required** if your linux distribution does not have a desktop environment e.g. WSL, Docker
124
+
Failure to set this up will result in authentication failures.
See the [shell script](docker/init.sh) used for docker in this repository
148
+
149
+
### Using Docker
150
+
Find docker instructions in the docker folder [here](docker)
151
+
152
+
## Uninstalling
153
+
1. Delete the CLI installation folder
154
+
2. If path enviroment variable had been set, remove it.
155
+
16
156
## Registering an application in Azure AD
17
157
18
-
> **Note:** this step is required if your client will be calling APIs that are protected by the Microsoft Identity Platform like Microsoft Graph.
158
+
> **Note:** this step is **NOT**required unless your client will be calling APIs that are protected by the Microsoft Identity Platform like Microsoft Graph OR using Client Certificate authentication option.
19
159
20
160
Follow the instructions in [Register an application for Microsoft identity platform authentication](register-app.md) to get an application ID (also know as a client ID).
21
161
22
-
### Creating the client application
23
-
24
162
Replace `YOUR_CLIENT_ID` with the client ID from your app registration.
25
163
26
164
## Executing the application
27
-
Navigate to your download folder and use the **mgc** command to run commands on the CLI SDK.
165
+
Navigate to your download folder and use the **mgc** (on Windows/Mac) or **./mgc** (on WSL or Linux) command to run commands on the CLI SDK.
166
+
28
167
Add -h to your commands to view additional commands.
Qn: Why am I not getting a response back after running a command?
84
224
85
-
mgc login
86
-
```
225
+
Ans:add --debug to your command
87
226
88
-
###Samples
89
-
You can find additional samples here:[CLI SDK samples](https://github.com/microsoftgraph/msgraph-cli/tree/main/samples)
227
+
## Samples
228
+
You can find additional samples here (contains sample commands for CMD, PowerShell & Bash)[CLI SDK samples](https://github.com/microsoftgraph/msgraph-cli/tree/main/samples)
90
229
91
230
92
231
> Note: This repository is for the .NET CLI. If you are looking for the Python CLI, it's been moved to the [msgraph-cli-archived](https://github.com/microsoftgraph/msgraph-cli-archived) repository
0 commit comments