Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit af1974d

Browse files
authored
Merge pull request #260 from microsoftgraph/chore/update-environment-setup
Add environment setup info
2 parents 1bbfb89 + b88fe25 commit af1974d

File tree

1 file changed

+110
-16
lines changed

1 file changed

+110
-16
lines changed

README.md

Lines changed: 110 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,137 @@
11
# Microsoft Graph CLI
22

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.
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.
44

55
## Required tools
66
A commandline tool should work on any terminal. We recommend:
77
- [Windows Terminal + version](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us)
8-
- MacOS terminal
8+
- MacOS (Minimum version: 10.12 Sierra) terminal
99
- PowerShell version 7.3.2
1010

1111
## Installation
12-
Download the CLI SDK to get started for
12+
Download the CLI SDK to get started for
1313
Windows, Mac, or Linux here on the assets link of the latest release: [CLI SDK Download](https://github.com/microsoftgraph/msgraph-cli/releases)
1414

15+
1516
### Windows
1617
1. Extract downloaded CLI tool for Windows to folder
17-
2. Execute program using **mgc** (on Windows/Mac) or **./mgc** (on WSL or Linux) command
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+
```
1874

19-
**Windows environment setup**
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:
2077

78+
```sh
79+
export PATH=$PATH:[path-to-the-cli-folder]
80+
```
2181

22-
### Mac
23-
1. Extract downloaded CLI tool for Mac to folder
24-
2. Execute program using **mgc** (on Windows/Mac) or **./mgc** (on WSL or Linux) command
82+
Adding a symbolic link into `/usr/bin` (not recommended) can be done with the command below:
2583

26-
**Mac environment setup**
84+
```sh
85+
sudo ln -s [path-to-the-cli-folder]/mgc /usr/bin
86+
```
2787

2888

2989
### Linux
90+
3091
Download from browser OR via Curl
92+
3193
``` bash
3294
curl -LO <link> && tar -xzf <filename>
3395
```
3496

35-
Add environment setup to ensure commands are not run every time. Edit environment files
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.
125+
126+
Required packages:
127+
128+
1. gnome-keyring
129+
2. dbus
130+
3. libsecret
131+
4. libcap
36132

37-
>**Note:** For linux users please run the following commands before authenticating
38133
``` bash
39-
sudo apt install gnome-keyring libsecret-1-0
134+
sudo apt-get install --assume-yes gnome-keyring libsecret-1-0
40135

41136
sudo setcap cap_ipc_lock=+ep $(which gnome-keyring-daemon)
42137

@@ -48,12 +143,11 @@ dbus-run-session -- echo "$KEYRING_PASSWORD" | gnome-keyring-daemon --daemonize
48143

49144
mgc login
50145
```
51-
**Linux environment setup**
52146

53-
--insert steps here
147+
See the [shell script](docker/init.sh) used for docker in this repository
54148

55149
### Using Docker
56-
Find docker instructions in the docker folder [here](https://github.com/microsoftgraph/msgraph-cli/tree/main/docker)
150+
Find docker instructions in the docker folder [here](docker)
57151

58152
## Uninstalling
59153
1. Delete the CLI installation folder
@@ -120,7 +214,7 @@ mgc login --strategy ClientCertificate
120214
Add -h to your command to view information that contains documentation links with permissions
121215

122216
## Check logged in user
123-
You can access the logged in user's details using:
217+
You can access the logged in user's details using:
124218
```bash
125219
mgc me get
126220
```

0 commit comments

Comments
 (0)