Sorry for my misunderstanding. If so, we could refer to the introduction in the official document: Disable access to Microsoft 365 services with PowerShell, We could disable all other servies except for teams related then assign them to users.
1.Identify the undesired services in the licensing plan by using the following syntax:
$LO = New-MsolLicenseOptions -AccountSkuId <AccountSkuId> -DisabledPlans "<UndesiredService1>", "<UndesiredService2>"...
Example: The following example creates a LicenseOptions object that disables the Office and SharePoint Online services in the licensing plan named litwareinc:ENTERPRISEPACK (Office 365 Enterprise E3).
$LO = New-MsolLicenseOptions -AccountSkuId "litwareinc:ENTERPRISEPACK" -DisabledPlans "SHAREPOINTWAC", "SHAREPOINTENTERPRISE"
2.Use the LicenseOptions object from Step 1 on one or more users.
To disable the services for an existing licensed user, use the following syntax:
Set-MsolUserLicense -UserPrincipalName <Account> -LicenseOptions $LO
To create a new account that has the services disabled, use the following syntax:
New-MsolUser -UserPrincipalName <Account> -DisplayName <DisplayName> -FirstName <FirstName> -LastName <LastName> -LicenseAssignment <AccountSkuId> -LicenseOptions $LO -UsageLocation <CountryCode>
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.