當您使用遠端 Windows PowerShell 連接到 Exchange Online 時, (存取被拒) 的錯誤
問題
當您嘗試使用遠端 Windows PowerShell 連接到 Microsoft Exchange Online 時,您收到下列錯誤訊息:
[outlook.office365.com] Connecting to remote server failed with the following error message: Access is
denied. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [].
PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenedFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null.
Supply a non-null argument and try the command again.
At D:\Users\Connect.ps1:7 char:21
+ Import-PSSession < < < < $Session
+ CategoryInfo : Invalid Data: (:) [Import-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId :
ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand
原因
這個問題是因為下列其中一個原因所造成:
解決方案
若要解決此問題,請使用 Microsoft 365 的 Exchange 管理中心,將使用者新增為系統管理員角色群組的成員。 如果要執行這項操作,請依照下列步驟執行:
- 以系統管理員身分登入 Microsoft 365 入口網站 (https://portal.office.com)。
- 按一下 [管理員],然後按一下 [Exchange]。
- 按一下 [權限] ,然後按一下 [管理員角色] 。
- 按兩下您要新增使用者的角色群組。 例如,如果您想要讓使用者擁有包含 Windows PowerShell 的完整存取權限,請按兩下 [組織管理]。
- 若要將使用者新增至清單,請按兩下 [成員] 底下的 [ 新增 ( ) ] 。
- 按一下 [儲存]。
如果您已啟用安全性預設值,請參閱使用含有或不含 MFA 的新式驗證連線到 Exchange Online PowerShell。
其他資訊
如需如何使用遠端 PowerShell 連接到 Exchange Online 的詳細資訊,請前往 使用遠端 PowerShell 連接至 Exchange Online。
是否仍需要協助? 前往 Microsoft Community。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應