Error validating credentials due to invalid username or password

SY_MSO 166 Reputation points
2021-12-09T17:11:45.827+00:00

Script that was run on Exchange Server.

What script does? Looks for user mailbox- look at user attribute, and if value of attribute is forced, extension attributes - (Calendar repair disable) It searches for all mailbox and see attribute repair disabled.

If value is forced, we set to true. We use two credential to run Powershell script. use on-prem accounts to start the schedule task, once the task is started on-prem, it connects to exchange online, This then uses. We see it trying to authentication, we see success logon, and failure logon, When it authenticate with ExO credentials, it gets password from a file, that gets encrypted password Need help to determine why one script works, and the other doesn't.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Microsoft 365 and Office Development Office JavaScript API
{count} votes

1 answer

Sort by: Most helpful
  1. KyleXu-MSFT 26,396 Reputation points
    2021-12-10T08:38:10.48+00:00

    @SY_MSO

    Do you mean that you cannot connect to Exchange online from your script? If so, you could add those commands below into your script:

    $User = "******@domain.onmicrosoft.com"  
    $PassWord = ConvertTo-SecureString -String "Password" -AsPlainText -Force  
    $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PassWord  
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection  
    Import-PSSession $Session -DisableNameChecking    
    

    It will connect to Exchange online automatically with the User and Password that contained in this script.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.