We have a need to white list our SharePoint Online tenant to certain domains for external sharing. Luckily for us, there is the SharingAllowedDomainList property in the Get/Set-SPOTenant, https://technet.microsoft.com/en-us/library/fp161390.aspx?f=255&MSPPError=-2147217396.

The documentation states:

Specifies a list of email domains that is allowed for sharing with the external collaborators. Use the space character as the delimiter for entering multiple values. For example, “contoso.com fabrikam.com”.

What is not clear, and cannot find any documentation on, is how to properly update this. If I have a list of domains already supplied, what happens when I need to add another programmatically? Is it simply a Set with this new domain and it will be appended or do I need to do a get first, append my domain to that variable, then set the domains with this?

Unfortunately, I'm not in a position to test this properly. I need to know what the behavior of the set command is if there are domains already listed. Is it an append or is it an overwrite?

1 Answer 1


If you are doing it for the first time, you need to set another property called SharingDomainRestrictionMode to AllowList mode using below cmdlet:

Set-SPOTenant -SharingDomainRestrictionMode AllowList -SharingAllowedDomainList "amit.com"

Every time you update the SharingAllowedDomainList, it overwrites the existing values. So, you can use below cmdlet to update the domains:

$allowedDomains = Get-SPOTenant | select -ExpandProperty SharingAllowedDomainList

Now, if you want to add a domain, you can run:

$allowedDomains += " xyz.com"

If you want to remove a domain, you can run

$allowedDomains = $allowedDomains.Replace("domainToRemove.com","")

If you want to update an existing domain, you can run:

$allowedDomains = $allowedDomains.Replace("domainToUpdate.com","updatedDomain.com")

And finally, when you are done updating domains

Set-SPOTenant -SharingAllowedDomainList $allowedDomains

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.