Hi @jennyKim
Thank you for posting in the community.
I checked your PowerShell scripts and found no problems.
Here are the PowerShell scripts I tested:
#Parameters
$SiteURL = "SiteURL"
$UserAccount = "******@XXXXX.onmicrosoft.com"
$PermissionLevel = "Contribute"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL
#grant access to sharepoint online site with powershell
Set-PnPWebPermission -User $UserAccount -AddRole $PermissionLevel
Here is the result of my test:
Since we can't reproduce your situation, we need to narrow down the problem and try some things.
1, Please go to Site Settings->site permissions ->permissions levels. Make sure the permission level in your command exists in your site.
2, If the problem persists, try a different computer. Check if the problem still exists.
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.