Skip to content

Commit 328ad28

Browse files
committed
Microsoft Graph example
1 parent 195835c commit 328ad28

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

articles/active-directory/external-identities/b2b-quickstart-invite-powershell.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
22
title: 'Quickstart: Add a guest user with PowerShell - Azure AD'
3-
description: In this quickstart, you learn how to use PowerShell to send an invitation to an external Azure AD B2B collaboration user.
3+
description: In this quickstart, you learn how to use PowerShell to send an invitation to an external Azure AD B2B collaboration user. You'll use the Microsoft Graph Identity Sign-ins and the Microsoft Graph Users PowerShell modules.
44
services: active-directory
55
author: msmimart
66
ms.author: mimart
77
manager: celestedg
8-
ms.reviewer: mal
9-
ms.date: 08/28/2018
8+
ms.date: 02/16/2022
109
ms.topic: quickstart
1110
ms.service: active-directory
1211
ms.subservice: B2B
@@ -17,14 +16,14 @@ ms.collection: M365-identity-device-management
1716

1817
# Quickstart: Add a guest user with PowerShell
1918

20-
There are many ways you can invite external partners to your apps and services with Azure Active Directory B2B collaboration. In the previous quickstart, you saw how to add guest users directly in the Azure Active Directory admin portal. You can also use PowerShell to add guest users, either one at a time or in bulk. In this quickstart, you’ll use the New-AzureADMSInvitation command to add one guest user to your Azure tenant.
19+
There are many ways you can invite external partners to your apps and services with Azure Active Directory B2B collaboration. In the previous quickstart, you saw how to add guest users directly in the Azure Active Directory admin portal. You can also use PowerShell to add guest users, either one at a time or in bulk. In this quickstart, you’ll use the New-MgInvitation command to add one guest user to your Azure tenant.
2120

22-
If you don’t have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
21+
If you don’t have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2322

2423
## Prerequisites
2524

2625
### PowerShell Module
27-
Install the [Azure AD V2 PowerShell for Graph module](/powershell/azure/active-directory/install-adv2) (AzureAD) or the [Azure AD V2 PowerShell for Graph module preview version](/powershell/azure/active-directory/install-adv2?view=azureadps-2.0-preview&preserve-view=true) (AzureADPreview).
26+
Install the [Microsoft Graph Identity Sign-ins module](/powershell/module/microsoft.graph.identity.signins/?view=graph-powershell-beta) (Microsoft.Graph.Identity.SignIns) and the [Microsoft Graph Users module](/powershell/module/microsoft.graph.users/?view=graph-powershell-beta) (Microsoft.Graph.Users).
2827

2928
### Get a test email account
3029

@@ -35,33 +34,32 @@ You need a test email account that you can send the invitation to. The account m
3534
Run the following command to connect to the tenant domain:
3635

3736
```powershell
38-
Connect-AzureAD -TenantDomain "<Tenant_Domain_Name>"
37+
Connect-MgGraph -Scopes user.readwrite.all
3938
```
40-
For example, `Connect-AzureAD -TenantDomain "contoso.onmicrosoft.com"`.
4139

4240
When prompted, enter your credentials.
4341

4442
## Send an invitation
4543

46-
1. To send an invitation to your test email account, run the following PowerShell command (replace **"Sanda"** and **sanda\@fabrikam.com** with your test email account name and email address):
44+
1. To send an invitation to your test email account, run the following PowerShell command (replace **"John Doe"** and **john\@contoso.com** with your test email account name and email address):
4745

4846
```powershell
49-
New-AzureADMSInvitation -InvitedUserDisplayName "Sanda" -InvitedUserEmailAddress sanda@fabrikam.com -InviteRedirectURL https://myapps.microsoft.com -SendInvitationMessage $true
47+
New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress John@contoso.com -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true
5048
```
51-
2. The command sends an invitation to the email address specified. Check the output, which should look similar to the following:
49+
1. The command sends an invitation to the email address specified. Check the output, which should look similar to the following example:
5250

53-
![PowerShell output showing pending user acceptance](media/quickstart-invite-powershell/powershell-azureadmsinvitation-result.png)
51+
![PowerShell output of the invitation command](media/quickstart-invite-powershell/powershell-mginvitation-result.png)
5452

5553
## Verify the user exists in the directory
5654

57-
1. To verify that the invited user was added to Azure AD, run the following command:
55+
1. To verify that the invited user was added to Azure AD, run the following command (replace **john\@contoso.com** with your invited email):
5856

5957
```powershell
60-
Get-AzureADUser -Filter "UserType eq 'Guest'"
58+
Get-MgUser -Filter "Mail eq '[email protected]'"
6159
```
62-
3. Check the output to make sure the user you invited is listed, with a user principal name (UPN) in the format *emailaddress*#EXT#\@*domain*. For example, *sanda_fabrikam.com#EXT#\@contoso.onmicrosoft.com*, where contoso.onmicrosoft.com is the organization from which you sent the invitations.
60+
1. Check the output to make sure the user you invited is listed, with a user principal name (UPN) in the format *emailaddress*#EXT#\@*domain*. For example, *john_contoso.com#EXT#\@fabrikam.onmicrosoft.com*, where fabrikam.onmicrosoft.com is the organization from which you sent the invitations.
6361

64-
![PowerShell output showing guest user added](media/quickstart-invite-powershell/powershell-guest-user-added.png)
62+
![PowerShell output showing guest user added](media/quickstart-invite-powershell/powershell-mginvitation-guest-user-add.png)
6563

6664
## Clean up resources
6765

@@ -70,7 +68,7 @@ When no longer needed, you can delete the test user account in the directory. Ru
7068
```powershell
7169
Remove-AzureADUser -ObjectId "<UPN>"
7270
```
73-
For example: `Remove-AzureADUser -ObjectId "sanda_fabrikam.com#EXT#@contoso.onmicrosoft.com"`
71+
For example: `Remove-AzureADUser -UserId john_contoso.com#EXT#@fabrikam.onmicrosoft.com`
7472

7573

7674
## Next steps
Loading
Loading

0 commit comments

Comments
 (0)