Some sharing settings are not inherited from the Teams to the channels,
E.g. disabling company wide sharing are not inherited and if it’s disabled at the teams level it needs to be done for associate channels.
$domain = "contoso"
$teamName = @(
"test",
"CTO"
)
$clientId = "xxxx"
$adminSiteURL = "https://$domain-Admin.SharePoint.com"
Connect-PnPOnline -Url $adminSiteURL -ClientId $clientId
$teamName | ForEach-Object {
$team = Get-PnPTeamsTeam -Identity $_
$m365GroupId = $team.GroupId
Get-PnPTenantSite | Where-Object { $_.Template -eq 'TEAMCHANNEL#1' -and $_.RelatedGroupId -eq $m365GroupId } | ForEach-Object{
$site = $_
$siteUrl = $site.Url
Connect-PnPOnline -Url $siteUrl
Set-pnptenantsite -url $siteUrl -DisableCompanyWideSharingLinks Disabled
}
}