New-ExoPSSession:unknown_user_type:未知用户类型

问题描述

使用PowerShell连接到Exchange 365,以为自定义域设置DKIM

我对Office 365为一堆自定义域设置DKIM感到非常沮丧。 我需要使用PowerShell登录到Exchange系统,并使用仅Microsoft可以发明的语法来做一些巫术。

这些是我的资源

https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps#install-and-maintain-the-exo-v2-module

https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps

安装依赖项

Install-Module -Name ExchangeOnlineManagement -requiredVersion 2.0.3
Set-ExecutionPolicy RemoteSigned
Import-Module ExchangeOnlineManagement

我对所有问题的回答都是“是”,这似乎行得通。

登录

$UserCredential = Get-Credential

我被要求提供我的管理员凭据,我以user@cortoso.onmicrosoft.com的形式输入它们,我也尝试了user@customdomain.com。当我通过Microsoft Web门户登录到Exchange管理员时,两者均可

下一条命令失败:

Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true -ExchangeEnvironmentName O365GermanyCloud

----------------------------------------------------------------------------
The module allows access to all existing remote PowerShell (V1) cmdlets in addition to the 9 new,faster,and more reliable cmdlets.

|--------------------------------------------------------------------------|
|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|--------------------------------------------------------------------------|
|    Get-CASMailBox                 |    Get-EXOCASMailBox                 |
|    Get-MailBox                    |    Get-EXOMailBox                    |
|    Get-MailBoxFolderPermission    |    Get-EXOMailBoxFolderPermission    |
|    Get-MailBoxFolderStatistics    |    Get-EXOMailBoxFolderStatistics    |
|    Get-MailBoxPermission          |    Get-EXOMailBoxPermission          |
|    Get-MailBoxStatistics          |    Get-EXOMailBoxStatistics          |
|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |
|    Get-Recipient                  |    Get-EXORecipient                  |
|    Get-RecipientPermission        |    Get-EXORecipientPermission        |
|--------------------------------------------------------------------------|

To get additional information,run: Get-Help Connect-ExchangeOnline or check https://aka.ms/exops-docs

Send your product improvement suggestions and Feedback to <cut>. For issues related to the module,contact Microsoft support. Don't use the Feedback alias for problems or support issues.
----------------------------------------------------------------------------

New-ExoPSSession : unkNown_user_type: UnkNown User Type.
In C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.3\ExchangeOnlineManagement.psm1:426 Zeichen:30
+ ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-ExoPSSession],Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession

如何继续登录Exchange以设置DKIM密钥?

解决方法

命令在没有ExchangeEnvironmentName的情况下有效:

Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true

所需用户为user@customdomain.com

,

就我而言,我的帐户已启用MFA。因此,有效的命令是:

Connect-ExchangeOnline -UserPrincipalName navin@contoso.com -ShowProgress $ true

替换您的用户名,并期望通过Microsoft身份验证器进行身份验证。