Hi @Frankster ,
This is for the tenant level PnP-PowerShell code:
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
#Connect to Tenant Admin Site
Connect-PnPOnline -url $TenantAdminURL -Interactive
#Disable External Sharing for the tenant
Set-PnPTenant -SharingCapability Disabled
This is for the site level PnP-PowerShell code:
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites"
#Connect to Tenant Admin Site
Connect-PnPOnline -url $TenantAdminURL -Interactive
#Disable External Sharing for a site
Set-PnPTenantSite -Url $SiteURL -SharingCapability Disabled
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".