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
Copy file name to clipboardExpand all lines: microsoftgraph/docs-conceptual/find-mg-graph-command.md
+17-13Lines changed: 17 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: "Using Find-MgGraphCommand cmdlet"
3
-
description: "Learn how to use the Find-MgGraphCommand to aid in discoverability of cmdlets."
2
+
title: Use Find-MgGraphCommand
3
+
description: Learn how to use the Find-MgGraphCommand to aid in discoverability of cmdlets.
4
4
5
5
ms.topic: how-to
6
6
ms.date: 01/22/2025
@@ -12,22 +12,24 @@ reviewer: maisarissi
12
12
#customer intent: As a PowerShell user, I want to use the Find-MgGraphCommand cmdlet to easily discover the API path that a command calls, so that I can efficiently work with Microsoft Graph PowerShell commands and understand the permissions required for each command.
13
13
---
14
14
15
-
# Using Find-MgGraphCommand cmdlet
15
+
# Use Find-MgGraphCommand
16
16
17
-
`Find-MgGraphCommand`aims to make it easier for you to discover which API path a command calls, by providing a URI or a command name.
17
+
`Find-MgGraphCommand`helps you discover which API path a command calls by providing a URI or command name.
18
18
19
-
The `Find-MgGraphCommand` cmdlet allows you to:
19
+
You can use the `Find-MgGraphCommand` cmdlet to:
20
20
21
21
- Pass a Microsoft Graph URL (relative and absolute) and get an equivalent Microsoft Graph PowerShell command.
22
22
- Pass a command and get the URL it calls.
23
-
- Pass a command or URI wildcard (.*) to find all commands that match it.
23
+
- Pass a command or URI wildcard, for example `.*`, to find all matching commands.
24
24
25
-
The output of this cmdlet also includes the permissions required to authenticate the specified cmdlet. For more information on cmdlet permissions, see [Using Find-MgGraphPermission](find-mg-graph-permission.md). Not all cmdlets have the permissions available on running this command. This is an ongoing feature, and permissions will continue to be added.
25
+
The output of this cmdlet also includes the permissions required to authenticate the specified cmdlet. For more information on discovering permissions, see [Using Find-MgGraphPermission](find-mg-graph-permission.md), which is a separate cmdlet dedicated to permissions discovery.
26
26
27
-
The permissions displayed don't show the privilege levels. To learn more, including how to choose permissions, permission type, and what is the most privileged/least privileged permission, use the corresponding API page doc.
27
+
The permissions displayed don't indicate privilege levels. For guidance on choosing permissions, understanding permission types, and identifying the most or least privileged permissions, refer to the documentation for the corresponding API page.
28
28
29
29
## Find Microsoft Graph PowerShell commands by URI
30
30
31
+
Before using the cmdlet, review the following syntax for reference.
Copy file name to clipboardExpand all lines: microsoftgraph/docs-conceptual/find-mg-graph-permission.md
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: "Using Find-MgGraphPermission cmdlet"
3
-
description: "Learn how to use the Find-MgGraphPermission to discover permissions related to a ___domain."
2
+
title: Use Find-MgGraphPermission
3
+
description: Learn how to use the Find-MgGraphPermission to discover permissions related to a ___domain.
4
4
5
5
ms.topic: how-to
6
6
ms.date: 01/22/2025
@@ -12,15 +12,16 @@ reviewer: maisarissi
12
12
#customer intent: As a Microsoft Graph PowerShell user, I want to find the identifier for a specific permission, so that I can accurately supply the permission-related parameters of commands like New-MgApplication and other application and consent related commands.
13
13
---
14
14
15
-
# Using Find-MgGraphPermission cmdlet
15
+
# Use Find-MgGraphPermission
16
16
17
-
The Microsoft Graph PowerShell SDK application requires users to have ___domain knowledge of both the semantics and syntax of Microsoft Graph API permissions used to authorize access to the API. The `Find-MgGraphPermission` cmdlet helps to answer the following questions:
17
+
The Microsoft Graph PowerShell SDK requires users to understand both the semantics and syntax of Microsoft Graph API permissions. The `Find-MgGraphPermission` cmdlet addresses the following questions:
18
18
19
19
- How do I find the values to supply to the permission-related parameters of commands like `New-MgApplication` and other application and consent related commands?
20
20
- What permissions are applicable to a certain ___domain? For example, application.
21
-
To use Microsoft Graph PowerShell to access Microsoft Graph, users must sign in to a Microsoft Entra application using the `Connect-MgGraph` command. Use the [Find-MgGraphCommand](find-mg-graph-command.md) to find which permissions to use for a specific cmdlet or API.
22
21
23
-
Currently, PowerShell commands and scripts have no way of validating user input that refers to permissions or providing an *auto-complete* user experience to help users accurately supply input to commands. This also affects commands or scripts implemented with the Microsoft Graph PowerShell SDK itself.
22
+
To use Microsoft Graph PowerShell to access Microsoft Graph, users must sign in to Microsoft Graph using the `Connect-MgGraph` cmdlet. Use the [Find-MgGraphCommand](find-mg-graph-command.md) to find which permissions to use for a specific cmdlet or API.
23
+
24
+
Currently, PowerShell commands and scripts can't validate user input that refers to permissions. They also don't provide an *auto-complete* experience to help users supply input accurately. This also affects commands or scripts implemented with the Microsoft Graph PowerShell SDK itself.
24
25
25
26
## Find permissions related to a given ___domain
26
27
@@ -76,4 +77,4 @@ Description : Allows the app to read all applications and service principals
title: "Get started with the Microsoft Graph PowerShell SDK"
3
-
description: "Get started with the Microsoft Graph PowerShell SDK by using it perform some basic tasks."
2
+
title: Get started with the Microsoft Graph PowerShell SDK
3
+
description: Get started with the Microsoft Graph PowerShell SDK by using it to perform some basic tasks.
4
4
5
5
author: msewaweru
6
6
manager: mwongerapk
7
7
ms.topic: quickstart
8
-
ms.date: 03/18/2025
8
+
ms.date: 07/23/2025
9
9
ms.author: eunicewaweru
10
10
11
11
#customer intent: As a PowerShell user, I want to learn how to use the Microsoft Graph PowerShell SDK, so that I can perform basic tasks using the Microsoft Graph REST API and authenticate with delegated access.
12
12
---
13
13
14
14
# Get started with the Microsoft Graph PowerShell SDK
15
15
16
-
In this guide, you'll use the Microsoft Graph PowerShell SDK to perform some basic tasks. If you haven't already, [install the SDK](installation.md) before following this guide.
16
+
In this Quickstart, you use the Microsoft Graph PowerShell SDK to perform some basic tasks. If you haven't already, [install the SDK](installation.md) before following this guide.
17
17
18
18
## API version
19
19
20
-
The SDK contains two modules, Microsoft.Graph and Microsoft.Graph.Beta that call the [Microsoft Graph REST API v1.0](/graph/api/overview?view=graph-rest-1.0&preserve-view=true) and [Microsoft Graph REST API beta](/graph/api/overview?view=graph-rest-beta&preserve-view=true), respectively. Cmdlets are available for the module that is installed.
20
+
The SDK contains two modules, Microsoft.Graph and Microsoft.Graph.Beta that call the [Microsoft Graph REST API v1.0](/graph/api/overview) and [Microsoft Graph REST API beta](/graph/api/overview?view=graph-rest-beta), respectively. Cmdlets are available for the module that is installed.
21
21
22
-
## Authentication
22
+
To get started with the SDK, follow these steps:
23
23
24
-
The PowerShell SDK supports two types of authentication: *delegated access*, and *app-only access*. In this guide, you'll use delegated access to sign in as a user, grant consent to the SDK to act on your behalf, and call Microsoft Graph.
24
+
1. Install either the `Microsoft.Graph` or `Microsoft.Graph.Beta` module, depending on which API version you want to use.
25
+
2. Import the module into your PowerShell session.
26
+
3. Authenticate using the appropriate permissions.
27
+
4. Begin making calls to Microsoft Graph using the available cmdlets.
25
28
26
-
For details on using app-only access for unattended scenarios, see [Use app-only authentication with the Microsoft Graph PowerShell SDK](app-only.md).
29
+
## Authentication
30
+
31
+
The PowerShell SDK supports two types of authentication: [*delegated access*](/graph/auth/auth-concepts#delegated-access-access-on-behalf-of-a-user), and [*app-only access*](/graph/auth/auth-concepts#app-only-access-access-without-a-user). In this guide, you use delegated access to sign in as a user, grant consent to the application to act on your behalf, and call Microsoft Graph.
32
+
33
+
For more details on using app-only access for unattended scenarios, see [Use app-only authentication with the Microsoft Graph PowerShell SDK](app-only.md).
27
34
28
35
### Determine required permission scopes
29
36
30
-
Each API in the Microsoft Graph is protected by one or more permission scopes. The user logging in must consent to one of the required scopes for the APIs you plan to use. In this example, we'll use the following APIs.
37
+
Each API in the Microsoft Graph is protected by one or more permission scopes. The user logging in must consent to one of the required scopes for the APIs you plan to use. In this example, we use the following APIs.
31
38
32
39
-[List users](/graph/api/user-list?view=graph-rest-1.0&preserve-view=true) to find the user ID of the logged-in user.
33
40
-[List joinedTeams](/graph/api/user-list-joinedteams?view=graph-rest-1.0&preserve-view=true) to get the Teams the user is a member of.
34
41
-[List channels](/graph/api/channel-list?view=graph-rest-1.0&preserve-view=true) to get the channels in a Team.
35
42
-[Send message](/graph/api/channel-post-messages?view=graph-rest-1.0&preserve-view=true) to send a message to a Team's channel.
36
43
37
-
The `User.Read.All` permission scope will enable the first two calls, and the `Group.ReadWrite.All` scope will enable the rest. These permissions require an account with the **Application Administrator** or **Cloud Application Administrator** role to grant consent. For more information, see [Microsoft Entra built-in roles](/entra/identity/role-based-access-control/permissions-reference).
44
+
The `User.Read.All` permission scope will enable the first two calls, and the `Group.ReadWrite.All` scope will enable the rest. Granting consent for these permissions typically requires an account with the **Privileged Role Administrator** role. For more information, see [Microsoft Entra built-in roles](/entra/identity/role-based-access-control/permissions-reference).
38
45
39
-
#### Using Find-MgGraphCommand to find required permissions
46
+
#### Use Find-MgGraphCommand to find required permissions
40
47
41
-
The `Find-MgGraphCommand` cmdlet can be used to discover the required permissions for another cmdlet. For example, to see all permissions that can be used to call `Get-MgUser`, run;
48
+
The `Find-MgGraphCommand` cmdlet can be used to discover the required permissions for another cmdlet. For example, to see all permissions that can be used to call `Get-MgUser`, run:
The command prompts you to go to a web page to sign in with your credentials. Once you've done that, the command indicates success with a `Welcome To Microsoft Graph!` message. You only need to sign in once per session.
76
+
The command prompts you to go to a web page to sign in with your credentials. Once you've done that, the command indicates success with a `Welcome To Microsoft Graph!` message. You only need to sign in once per PowerShell session (that is, until you close and reopen your PowerShell window or call `Disconnect-MgGraph`).
70
77
71
78
> [!TIP]
72
79
> You can add additional permissions by repeating the `Connect-MgGraph` command with the new permission scopes.
73
80
74
81
## Call Microsoft Graph
75
82
76
-
Now that you're signed in, you can start making calls to Microsoft Graph.
After signing in, you can begin making calls to Microsoft Graph.
79
84
80
-
### Get the signed-in user
85
+
### Get a user
81
86
82
-
In this section, you'll locate the signed-in user and get their user Id. You'll need the user Id as a parameter to the other commands you'll run later. Start by running the following command.
87
+
In this section, you identify a user in the list returned by `Get-MgUser` and store their information in the `$user` variable, which is used as a parameter in subsequent commands. Start by running the following command.
83
88
84
89
```powershell
85
90
Get-MgUser
86
91
```
87
92
88
-
This command outputs a listing of users in your Microsoft 365 organization.
93
+
This command outputs a listing of users in your Microsoft 365 organization; in organizations with many users, the output may be limited or paginated, so consider using filtering to locate specific users.
89
94
90
95
```powershell
91
96
Id DisplayName Mail UserPrincipalName
@@ -101,35 +106,37 @@ ce73bdb5-bf12-405e-ab85-40122fdd6eb7 Brian Johnson (TAILSPIN) [email protected]
101
106
df1347a3-7ce7-4b4d-8aab-7c65b5c907b9 Cameron White CameronW@contoso…
102
107
```
103
108
104
-
You can use an [OData filter](use-query-parameters.md#filter-parameter) to help locate the specific user you want. Run the following command, replacing `Megan Bowen` with the display name of the user you signed in with.
109
+
An OData filter is a query option that allows you to filter results based on specific property values. You can use an [OData filter](use-query-parameters.md#filter-parameter) to help locate the specific user you want. OData filters allow you to query data using expressions such as `property eq 'value'`; see [OData query parameters overview](/graph/query-parameters) for more details on the syntax.
110
+
111
+
Run the following command, replacing `[email protected]` with the user principal name of an actual user in your organization that you want to use.
Verify the command worked by entering the following command.
111
118
112
119
```powershell
113
120
$user.DisplayName
114
121
```
115
122
116
123
### List the user's joined teams
117
124
118
-
Now use the user's Id as a parameter to the `Get-MgUserJoinedTeam` command.
125
+
Use the value of `$user.Id` as the `-UserId`parameter in the `Get-MgUserJoinedTeam` command.
119
126
120
127
```powershell
121
128
Get-MgUserJoinedTeam -UserId $user.Id
122
129
```
123
130
124
-
Just like the `Get-MgUser` command, this command gives a list of teams. Select one of the user's joined teams and copy its `Id`, to use in the next command.
131
+
Like `Get-MgUser`, this command returns a list of teams. Select one of the user's joined teams and copy its `Id` to use in the next command.
125
132
126
133
```powershell
127
134
$team = Get-MgTeam -TeamId ID_FROM_PREVIOUS_STEP
128
135
```
129
136
130
137
### List team channels
131
138
132
-
Now use the team's Id as a parameter to the `Get-MgTeamChannel` command, following a similar pattern of listing all channels, then filtering the list to get the specific channel you want.
139
+
Now use the team's Id as a parameter to the `Get-MgTeamChannel` command. First, list all channels, then filter the list to get the specific channel you want.
This command differs from the previous commands you used. Instead of querying data, it's creating something. In Microsoft Graph, this command translates to an HTTP `POST`, and it requires an object in the body of that post. In this case, the object is a [chatMessage](/graph/api/resources/chatmessage). The `-Body` parameter to the command maps to the `body` property on `chatMessage`. Other properties are mapped in a similar way, so you can change the message you send. For example, to send an urgent message use the following command.
154
+
This command differs from the previous commands you used. Instead of querying data, it's creating something. In Microsoft Graph, this command translates to an HTTP `POST`, and it requires an object in the body of that post. In this case, the object is a [chatMessage](/graph/api/resources/chatmessage). The `-Body` parameter is a hashtable that maps to the `body` property of the `chatMessage` resource. Other properties are mapped in a similar way, so you can change the message you send. For example, to send an urgent message use the following command.
Use the `Disconnect-MgGraph` command to sign out. This command ends your current session and revokes the authentication token for the active PowerShell session, ensuring your credentials are no longer available until you sign in again.
156
163
157
164
```powershell
158
165
Disconnect-MgGraph
159
166
```
160
167
161
168
## Next steps
162
169
163
-
-[Learn how to navigate the SDK](navigating.md).
164
-
-[Use app-only authentication with the Microsoft Graph PowerShell SDK](app-only.md).
170
+
Now that you've completed the basic tasks, explore the following resources to deepen your understanding and expand your usage of the Microsoft Graph PowerShell SDK:
171
+
172
+
-[Learn how to navigate the SDK](navigating.md)
173
+
-[Use app-only authentication with the Microsoft Graph PowerShell SDK](app-only.md)
0 commit comments