【问题标题】:How can I close Office365 Exchange Powershell connections如何关闭 Office365 Exchange Powershell 连接
【发布时间】:2019-10-08 15:01:14
【问题描述】:

当我连接到 Office365 Exchange 时,会出现一条错误消息。如何关闭此连接?

脚本:

$userCredential = Get-AutomationPSCredential -Name 'automation'


$ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $userCredential -Authentication Basic -AllowRedirection
Import-PSSession $ExoSession

Get-Mailbox -ResultSize Unlimited -Filter {RecipientTypeDetails -eq "UserMailbox" -or RecipientTypeDetails -eq "SharedMailbox" -or RecipientTypeDetails -eq "RoomMailbox" -or RecipientTypeDetails -eq "DiscoveryMailbox"} | Set-Mailbox -AuditEnabled $true -AuditLogAgeLimit 180 -AuditAdmin Update, MoveToDeletedItems, SoftDelete, HardDelete, SendAs, SendOnBehalf, Create, UpdateFolderPermission -AuditDelegate Update, SoftDelete, HardDelete, SendAs, Create, UpdateFolderPermissions, MoveToDeletedItems, SendOnBehalf -AuditOwner UpdateFolderPermission, MailboxLogin, Create, SoftDelete, HardDelete, Update, MoveToDeletedItems

错误:

New-PSSession : [outlook.office365.com] Processing data from remote server outlook.office365.com failed with the 
 following error message: 
 [AuthZRequestId=fe5eb99c-df73-4899-b445-ad91e0ecf1f3][FailureCategory=AuthZ-AuthorizationException] Fail to create a 
 runspace because you have exceeded the maximum number of connections allowed : 3 for the policy party : MaxConcurrency. 
 Please close existing runspace and try again.
 Policy: CN=GlobalThrottlingPolicy_cfaee113-6e8e-4889-aa2c-99baf345f85f,CN=Global Settings,CN=ExchangeLabs,CN=Microsoft 
 Exchange,CN=Services,CN=Configuration,DC=eurprd04,DC=prod,DC=outlook,DC=com; 
 LockRemaining: 00:00:00 For more information, see the about_Remote_Troubleshooting Help topic.
 At line:4 char:15
 + ... xoSession = New-PSSession -ConfigurationName Microsoft.Exchange -Conn ...
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], 
 PSRemotingTransportException
 + FullyQualifiedErrorId : IncorrectProtocolVersion,PSSessionOpenFailed

【问题讨论】:

  • 您是否要测试连接是否失败?
  • 我们还没有收到您的来信。我的回答解决了您的问题吗?如果是这样,请点击左侧的✓ 考虑accepting。这将帮助其他有类似问题的人更轻松地找到它。

标签: azure powershell automation exchange-server ps


【解决方案1】:

您可以在完成代码后立即关闭/删除会话:

# your code
# ...

if ($ExoSession) { Remove-PSSession -Session $ExoSession -ErrorAction SilentlyContinue } }

或者,通过添加此行创建新会话以首先删除所有可能的现有会话:

Get-PSSession | Where-Object { $_.ConfigurationName -eq 'Microsoft.Exchange' } | Remove-PSSession -ErrorAction SilentlyContinue

希望有帮助

【讨论】:

    猜你喜欢
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 2014-03-10
    • 2016-07-14
    • 1970-01-01
    • 2010-09-22
    相关资源
    最近更新 更多