if(!$CreateSharedConfiguration) { if ($AuthoritativeOnly) { $acceptedDomains = @(get-accepteddomain -organization $RoleTenantOrganizationFullPath ...

if(!$CreateSharedConfiguration)          {            if ($AuthoritativeOnly)            {               $acceptedDomains = @(get-accepteddomain -organization $RoleTenantOrganizationFullPath | where {$_.DomainType -eq "Authoritative"});            }            else            {               $acceptedDomains = @(get-accepteddomain -organization $RoleTenantOrganizationFullPath);            }            # sort the domains and put the initial domain at the end of the list. This is because failures after the primary GLS domain is related cause            # organization lookup (get-organization -XXXX or set-foo -organization XXX) to fail because it isnt not in GLS. So this makes retries            # more successfull if the primary GLS entry for the organization name still exists.            $acceptedDomains = @($acceptedDomains | sort -Property InitialDomain);            foreach($acceptedDomain in $acceptedDomains)            {               $domainname = $acceptedDomain.DomainName.ToString();               remove-managementendpointhook -DomainName:$domainname -ExternalDirectoryOrganizationId:$RoleTenantExternalDirectoryOrganizationId            }          }