Allow Access Requests Email Settings In SharePoint Site Using PnP PowerShell

When new users get access denied to the site, they use the access request feature to inform the Site Owner to grant them the access.
 
From the Site Permissions  -> Access Requests Settings -> Allow Access Requests feature has the option for setting the email. So, whenever a user requests access to the site/ file/folder, an email will be sent to notify the user to provide them the access.

 
If we remove the email from the "Allow Access Requests" settings, this feature gets disabled and the new user won't notify the user when they need access.
 
To enable this email setting and send the notification to the owner, use the below PnP PowerShell snippets .
  1. $cred = Get-Credential    
  2. Connect-PnPOnline -Url https://<tenant>.sharepoint.com -Credential $cred    
  3. Set-PnPRequestAccessEmails -Emails ktskumar@<tenant>.onmicrosoft.com  
To add multiple emails to the settings, use the below cmdlet.
  1. Set-PnPRequestAccessEmails -Emails @( ktskumar@<tenant>.onmicrosoft.com; user1@<tenant>.onmicrosoft.com )    
The below PnP Powershell snippet is used to get the emails associated to allow access requests settings.
  1. $cred = Get-Credential      
  2. Connect-PnPOnline -Url https://<tenant>.sharepoint.com -Credential $cred      
  3. Get-PnPRequestAccessEmails