Hello @Mukherjee, Nilanjan ,
Welcome to Q&A Forum!
This is because the Connect-PnPOnline command with the Credential parameter is not work to MFA enabled accounts.
If you have an account secured with MFA, when using PnP PowerShell you have to use the weblogin option which shows a popup to support MFA. It's an interactive process that you couldn't implement in a build pipeline. That's just the consequence of using MFA which always requires user interaction.
Please use the below PnP powershell command:
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin
OR
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive
For more information, please refer to "Connect-PnPOnline".
Thanks,
Echo Du
========================
Updated Answer ======================
Hi @Mukherjee, Nilanjan ,
Please following steps:
1.Update the module to latest version then compare the result:
Update-Module SharePointPnPPowerShell*
2.You have to connect with Connect-PnPOnline -PnPManagementShell
and then you will receive a code to enter on https://microsoft.com/devicelogin
Connect-PnPOnline -Url "https://xxxx.sharepoint.com/" -PnPManagementShell
3.Type https://microsoft.com/devicelogin on the browser, where you will need to login with credentials for an account that must have the Application Admin role assigned to them in the Admin Center, and then you can consent to give PnP Management Shell access to your tenant.
4.After that, you should be able to login with Connect-PnPOnline -Url <url>
again.
Thanks,
Echo Du
===========================
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.