我一直在尝试找到一种将Office 365外壳的用户名,密码和令牌代码直接输入终端的方法,并且没有正常的辅助GUI窗口弹出。目前,我有一个使用以下命令登录的基本脚本:
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse).FullName | Where-Object {$_ -notmatch "_none_"} | Select-Object -First 1)
Connect-MSOLService
Import-PSSession (New-ExoPSSession -UserPrincipalName USER@domain.tld) -AllowClobber -DisableNameChecking
是否甚至可以通过GUI严格使用TUI来输入凭据?
答案 0 :(得分:0)
不要猜测如何执行X或Y。这只会导致您走上一条非常沮丧的道路。始终查看帮助文件和在线文档。
这些天来,您要尝试的是一种惯例,并且已从Microsoft和许多其他Web资源中得到了充分记录。有特定的模块可以帮助解决此用例。
Connect to Exchange Online PowerShell using multi-factor authentication
使用MFA连接到Exchange Online PowerShell
1。在本地计算机上,打开Exchange Online远程PowerShell模块(Microsoft Corporation> Microsoft Exchange Online Remote PowerShell模块)。
2。您需要运行的命令使用以下语法:
Connect-EXOPSSession -UserPrincipalName <UPN> [-ConnectionUri <ConnectionUri> -AzureADAuthorizationEndPointUri <AzureADUri>]
Connect to Office 365 PowerShell
步骤2:为Office 365订阅连接到AzureAD
>使用以下命令连接到Office 365订阅的Azure AD: 帐户名和密码或具有多重身份验证(MFA), 从Windows PowerShell命令提示符下运行以下命令之一 不必提高)。
Exchange Online PowerShell Module has been around since circa 2016 from the MFA PowerShell team
画廊中甚至还有一个脚本,专门用于使用MFA的EXO。
Connect to Exchange Online PowerShell using multi-factor authentication (MFA)
如果要使用多因素身份验证(MFA)连接到 Exchange Online PowerShell,您不能定期使用说明 连接到Exchange Online PowerShell以使用远程PowerShell来 连接到Exchange Online。
下载:MFA.ps1