A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
Hi @TSERKOVNYUK, Oleg ,
I tested the script with the new version "PnP.PowerShell" and old "SharePointPnPPowerShellOnline 3.29.2101.0" installed in local, the script will throw the same error (Only SharePointPnPPowerShellOnline 3.29.2101.0" installed won't throw the error):
For this issue, I suggest you can verify if the new PnP.PowerShell installed in your local using this command:
Get-Module -Name PnP.PowerShell -ListAvailable
If it listed the version details like this, this mean the "PnP.PowerShell" installed:
Then the error is because of new version "PnP.PowerShell" has removed Update function for [PnP.PowerShell.Commands.Model.SPOSite] .
A solution is specify which module to use using Import-Module:
Import-Module -Name SharePointPnPPowerShellOnline
$url = 'https://companygroup.sharepoint.com/sites/TeamBlockPolicy'
Connect-pnponline $url -useweblogin
$context = Get-PnPContext
$site = Get-PnPTenantSite -Url $url
$site.ConditionalAccessPolicy = [Microsoft.Online.SharePoint.TenantManagement.SPOConditionalAccessPolicyType]::BlockAccess
$site.Update()
Invoke-PnPQuery
The error message will gone:
Thanks
Best Regards
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.