Hi @Saida SADIKI,
Thank you for posting in this community.
First, I would like to confirm with you about how you created your Credentials.
Let me give you an example here:
$SiteURL="https://domain.sharepoint.com/sites"
$UserName="user@domain.onmicrosoft.com"
$Password = "userpassword"
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
try{
#connect to sharepoint online site using powershell
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
write-host "Connect successfully" -foregroundcolor green
}catch{
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
a
Thank you for your time and efforts in advance.
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.