Hi @nader hadjebi ,
Users might get that error if they are not global admin. Please check your account roles.
Microsoft 365 admin center > Users > Active users > click user name > Roles
And have you check you PowerShell codes? you could try the following PnP PowerShell codes to check wether you still get this error.
PnP PowerShell codes:
$SiteURL="https://tenant-admin.sharepoint.com/"
$UserName="your user name"
$Password = "your password"
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
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.