无法使用PowerShell连接到Office 365

我想通过PowerShell连接到Office 365,参考教程一个非常简单的任务。 但显然不适合我。

我想我错过了一个简单而重要的琐事。

一些信息:

  • 许可证是Office 365 Buisness Essential
  • Azure AD正在运行
  • 我可以使用PowerShell远程(WinRM)与其他服务器
  • 我使用pipe理员帐户
  • 我使用我的域名,并尝试了onmicrosoft.com域名
  • 双因素身份validation(附加安全validation)已configuration

我尝试了以下

PS C:\>Import-Module MSOnline PS C:\>$msolcred = get-credential PS C:\>connect-msolservice -credential $msolcred connect-msolservice : The user name or password is incorrect. Verify your user name, and then type your password again. 

 PS C:\> $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $msolcred -Authentication Basic -AllowRedirection New-PSSession : [ps.outlook.com] Connecting to remote server ps.outlook.com failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic. 

我使用了不同的连接uri

 PS C:\> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $msolcred2 -Authentication Basic -AllowRedirection New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : [ClientAccessServer=VI1PR05CA0019,BackEndServer=,RequestId=5d73dec9-b3ee-4e71-9ddd-bdaac8f79998,TimeStamp=3/7/2015 8:17:50 AM] [FailureCategory=LiveID-InvalidCreds] Access Denied For more information, see the 

帮助真的很感激!

它看起来不像PowerShell for O365支持双因素身份validation。

http://community.office365.com/en-us/f/148/t/222763.aspx

“如果pipe理员帐户已启用多因素身份validation,PowerShell在通过此pipe理员帐户连接到PowerShell时将不起作用。请确保您创build具有强密码的服务帐户以运行PowerShell脚本,并且不要为该帐户启用多因素身份validation“。