I'm trying to create an automation which involves connecting to exchange online. I'm unable to achieve this because whenever I issue the Connect-Exchange command with valid credentials provided, it asks for MFA (multi-factor authentication) - which cannot be automated. How can I achieve an automation with this? Any ideas? Thanks!
$password = ConvertTo-SecureString 'MySecretPassword' -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ('user@company.com', $password)
Connect-ExchangeOnline -Credential $credential