Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TenantDomain detection isn't correct #16

Open
cornholioso opened this issue Dec 1, 2020 · 0 comments
Open

TenantDomain detection isn't correct #16

cornholioso opened this issue Dec 1, 2020 · 0 comments

Comments

@cornholioso
Copy link

Regarding: https://github.com/nickrod518/PowerShell-Scripts/blob/master/MSO/OneDrive.psm1

Some assumptions are made with the following statement which are not always true - eg. user email may be user@company.org however the onmicrosoft domain may be different, say companyxy.onmicrosoft.com and the SPO domain is based on this
[string] $TenantDomain = (ConvertTo-Domain $UserPrincipalName)

The following would get the correct name:

    $domains = get-msoldomain                           ## get a list of all domains in tenant
    foreach ($domain in $domains) {                     ## loop through all these domains
        if ($domain.name.contains('onmicrosoft')) {     ## find the onmicrosoft.com domain
            $onname = $domain.name.split(".")           ## split the onmicrosoft.com domain when found at the period. Will produce an array that contains each string as an element
            $tenantname = $onname[0]                    ## the first string in this array is the name of the tenant
        }                                               ## end of find the on.microsoft.com domain
    }          
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant