title: Error when connecting to AzureAD powershell
body: <p>I am using powershell to extract O365 license information, the command I am using to connect to AzureAD is: </p>
  
  <pre><code>$cred = get-credential
  Connect-AzureAD -Credential $cred
  </code></pre>
  
  <p>This script runs successfully when using my own O365 credentials however when I use the newly created service account (after the sync has completed) I get the following error:</p>
  
  <pre><code>*connect-azuread : One or more errors occurred.: parsing_wstrust_response_failed: Parsing WS-Trust response failed
  At line:4 char:1
  + connect-azuread -Credential $cred
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : AuthenticationError: (:) [Connect-AzureAD], AadAuthenticationFailedException
      + FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD*
  </code></pre>
  
  <p>The company does use multi-factor authentication however it is turned off for the service account </p>
  
  <p>When running command:</p>
  
  <pre><code>Connect-AzureAD -Credential $cred
  $error[0] | select *
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>*ErrorRecord                 : One or more errors occurred.: parsing_wstrust_response_failed: Parsing WS-Trust response failed
  WasThrownFromThrowStatement : False
  Message                     : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 
                                One or more errors occurred.: parsing_wstrust_response_failed: Parsing WS-Trust response failed
  Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
  InnerException              : 
  TargetSite                  : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
  StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception 
                                exception)
                                   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                                   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                                   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                                   at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object 
                                inputToProcess)
                                --- End of stack trace from previous location where exception was thrown ---
                                   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                                   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                                   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
                                   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
  HelpLink                    : 
  Source                      : System.Management.Automation
  HResult                     : -2146233087*
  </code></pre>
  
  <p>Does anyone have any clues as to why this is happening? Any advice/workarounds would be great.</p>