如何使用 New-MgInvitation 邀请新的外部用户进入您的目录

邀请新的外部用户进入您的目录

组织邀请外部用户加入其 Microsoft Entra ID 目录,以便与组织外的个人协作。这允许受控共享资源并提供临时访问权限,同时使外部人员能够使用其现有凭据。

使用 Microsoft Graph PowerShell 邀请新的外部用户

前提条件

在使用 New-MgInvitation cmdlet 之前,请确保以下事项:

  • The Microsoft Graph PowerShell module is installed. If not, install it using this script:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the following permissions to invite external users to access applications.
    User.Invite.All, User.ReadWrite.All, Directory.ReadWrite.All,

使用 New-MgInvitation 命令邀请新的外部用户进入您的目录

New-MgInvitation cmdlet 可用于 Microsoft Graph PowerShell 中,邀请新的外部用户进入您的目录。语法如下:

New-MgInvitation
[-ResponseHeadersVariable <String>]
[-AdditionalProperties <Hashtable>]
[-Id <String>]
[-InviteRedeemUrl <String>]
[-InviteRedirectUrl <String>]
[-InvitedUser <IMicrosoftGraphUser>]
[-InvitedUserDisplayName <String>]
[-InvitedUserEmailAddress <String>]
[-InvitedUserMessageInfo <IMicrosoftGraphInvitedUserMessageInfo>]
[-InvitedUserSponsors <IMicrosoftGraphDirectoryObject[]>]
[-InvitedUserType <String>]
[-ResetRedemption]
[-SendInvitationMessage]
[-Status <String>]
[-Headers <IDictionary>]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

使用 New-MgInvitation cmdlet 的示例用例和脚本

示例 1:邀请用户并发送默认邀请邮件

New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress John@contoso.com -InviteRedirectUrl "https://myapplications.microsoft.com" -SendInvitationMessage:$true

示例 2:邀请用户并将用户类型设置为 member

New-MgInvitation -InvitedUserDisplayName "John Doe" -InvitedUserEmailAddress John@contoso.com -InviteRedirectUrl "https://myapplications.microsoft.com" -InvitedUserType Member

支持的参数

下表包含一些可与 New-MgInvitation 命令一起使用以邀请外部用户进入您的目录的参数。

参数 描述
-BodyParameter 此参数向外部用户发送邀请。
-Headers 此参数允许您向请求添加可选标头。
-Id 此参数为实体分配只读唯一标识符。
-InvitedUserType 此参数确定被邀请用户的 userType。
-InviteRedeemUrl 此参数指定用户可用于兑换其邀请的 URL。

使用 Graph PowerShell 脚本邀请外部用户进入您的目录的限制

  • Graph PowerShell 要求 IT 管理员从 Azure AD PowerShell 升级并熟悉 PowerShell 脚本。
  • Microsoft Graph 对 API 调用施加速率限制,这可能影响批量邀请,并导致一次邀请大量外部用户时出现延迟或失败。
  • 虽然邀请消息可以自定义,但对邀请工作流的高级修改可能需要复杂的脚本编写。
  • 识别和排查错误可能耗时且需要技术专长。
  • 缺乏直观界面使整体体验不够友好,尤其对脚本新手而言。

ADManager Plus亮点

ManageEngine ADManager Plus 是一款身份治理和管理解决方案,具备全面的 Microsoft Entra ID 管理和报告功能,消除了复杂 PowerShell 脚本的麻烦。其直观且用户友好的界面让您在几分钟内简化最复杂的管理任务。

这就是它如何将您的 AD 管理提升到新水平:

  • 提供易于使用的界面,用于 管理报告 用户,无需复杂的 PowerShell 脚本或 Graph API 知识。
  • 通过 自动化 功能简化批量操作,优化大规模环境,消除复杂脚本的需求。
  • 使用预构建或 自定义模板 标准化管理和报告任务。
  • 生成 200 多个预设报告,支持 自定义 并导出为 CSV 或 HTML 等多种格式。
  • 委派 特定管理和报告任务给技术人员,而不授予过多权限。

不再为 PowerShell 操作烦恼!使用 ADManager Plus 轻松管理 Microsoft Entra ID。

 
  • 使用 Microsoft Graph PowerShell 邀请外部用户进入您的目录
  • 使用 Graph PowerShell 脚本邀请外部用户的限制
  • ADManager Plus亮点
Active Directory管理与报告的一站式解决方案
电子邮件下载链接 Email the ADManager Plus download link