Because your trying to use a User to authentication it will use the Authorization code oAuth flow which requires user interaction (unless there is a cache refresh token which is only going to work for a limited amount of time). If you want to develop unattended scripts against Exo then look to use the certification authentication (which use the client credentials oauth flow) see https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps
unable to connect to exchangeOnline with credential in powershell script
Hi all,
I'm working on powershell scripts which should interact with exchange online.
I managed to do it in my laptop, with the following command:
Connect-ExchangeOnline -Credential $UserCredential -ShowBanner:$False -Verbose -EnableErrorReporting -LogDirectoryPath $logDirPath -LogLevel
All
and got the following reporting info:
Successfully acquired token based on Credential flow;Successfully got a token from AAD;SessionPrefixName:ExchangeOnlineInternalSession
Now, when I deploy my scripts in the test vm which has the same configuration, they failed to connect:
3.0.0 ExchangeOnlineManagement
1.1.183.66 MSOnline
I get the following report:
,CorrelationID: - Could not acquire token silently need UI authentication. No account or login hint was passed to the AcquireTokenSilent call
Do you know how it s possible and how to solve it?
regards
Mat