sharepoint online – PowerShell PnP does not contain a method named ‘SetUseAccessRequestDefaultAndUpdate’


Any thoughts on why this line has started failing (I’ve uninstalled and re-installed PnP):
$web.SetUseAccessRequestDefaultAndUpdate($true)

Getting error message:
Method invocation failed because (Microsoft.SharePoint.Client.Web) does not contain a method named ‘SetUseAccessRequestDefaultAndUpdate’.

We’ve been using this script for several months now, and it’s started failing.

Enable access requests to the owner group of the site using PnP PowerShell:
To set access requests to the site owners, use:

#Set Variables 
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing" 
#Connect to PNP Online 
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) 

#Get the Web 
$Web = Get-PnPWeb 

#Enable Access Request for the site to the Owners Group 
$Web.SetUseAccessRequestDefaultAndUpdate($True) 
$Web.Update() 
$Web.Context.ExecuteQuery()

#Read more: https://www.sharepointdiary.com/2016/10/sharepoint-online-access-request-email-settings-powershell.html#ixzz6aODUbUl9