Anonymous sharing link is by default disabled in a modern SharePoint site in Office 365
To enable it for all your SharePoint sites use this script:
$userCredential= Get-Credential
Connect-SPOService-Url https://NAMEOFYOURTENANT-admin.sharepoint.com -Credential $userCredential
$sites =Get-SPOSite -Limit ALL -includepersonalsite:$true
Foreach($sitein $sites)
{
Set-SPOSite-Identity $site.Url -SharingCapability ExternalUserAndGuestSharing
}
Write-Host("ExternalUserAndGuestSharingis nowupdated for all sites.")