我正在尝试构建一个脚本,在其中我使用委托的管理权限。我要做的就是这个。
$ConnectionUri = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=$TenantDefaultDomainName"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $ConnectionUri -Credential $Office365Credentials -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber这很棒,而且连接得很好,但我的印象是,这是一种旧的方法,因为有些cmdlet很简单,不使用委托。例如,我想获取用户日历的名称,并尝试使用
Get-MailboxFolderStatistics -Identity $user -FolderScope Calendar但是代理命令中出现了一个错误,即委托用户应该为null。因此,我想尝试使用新的cmdlet,但是几乎找不到任何关于委托的信息,下面的引用是:https://learn.microsoft.com/en-us/powershell/module/exchange/connect-exchangeonline?view=exchange-ps。
我想出了这个语法,但它根本不起作用。
Connect-ExchangeOnline -DelegatedOrganization $TenantDefaultDomainName -Credential $MyOffice365PartnerCredentials这是我要犯的错误。
New-ExoPSSession : One or more errors occurred.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.4\netFramework\ExchangeOnlineManagement.psm1:475 char
:30
+ ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-ExoPSSession], AggregateException
+ FullyQualifiedErrorId : System.AggregateException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession发布于 2021-03-27 09:27:12
我在GitHub上打开了一个问题,因为这不可能是我想要的行为,@chrisda给了我这个回复。
“这是在黑暗中拍摄,但尝试使用-UserPrincipalName参数连接-交换在线:”
Connect-ExchangeOnline -DelegatedOrganization $TenantDefaultDomainName -UserPrincipalName <MyOffice365PartnerUPN>不可思议的是,在使用connect时,您可以使用所有常规命令,比如get-mailboxfolderstatistics,这些命令与我在问题中前面提到的老伙伴方法不兼容。希望这对我以外的人有帮助,在MS文档或我能在互联网上找到的任何其他地方都没有任何参考。
参考资料:https://github.com/MicrosoftDocs/office-docs-powershell/issues/7458
发布于 2021-04-03 20:44:35
当帐户上启用了MFA时,我犯了这个错误。
https://stackoverflow.com/questions/66696888
复制相似问题