Forum Discussion
Adam Weldon-Ming
May 20, 2020Brass Contributor
Delegated Admin tenants and adding a list of the same users across multiple tenants PowerShell
Hello To the point: We are managing clients tenants through Partner Centre - However, there is limited controls. i.e. Cannot properly manage SharePoint, Convert users mailboxes to Shared Ma...
- May 21, 2020
Worked it out 😄
Get-MsolPartnerContract -All | ForEach { $tenantprefix = [string]$_.DefaultDomainName $TenantId = [string]$_.TenantId.Guid Import-Csv .\users1.csv | foreach { $newUPN = $_.UserPrincipalName + "@" + $tenantprefix $newUPN = [string]$newUPN New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $newUPN -Password $_.Password -ForceChangePassword:$true -PasswordNeverExpires:$true -TenantId $TenantId } }
VasilMichev
May 20, 2020MVP
It's been a long time since I had a partner account, but you should be able to get the domain name from the output of Get-MsolPartnerContract, or just call Get-MsolDomain for each tenant? Then append to the UPN.
Adam Weldon-Ming
May 21, 2020Brass Contributor
Thanks, VasilMichev
I thought this too but I get all the clients domains, if I filter by -Match ".onmicrosoft.com" I get mostly 2 returns.
contoso.mail.onmicrosoft.com and contoso.onmicrosoft.com
- Adam Weldon-MingMay 21, 2020Brass Contributor
Worked it out 😄
Get-MsolPartnerContract -All | ForEach { $tenantprefix = [string]$_.DefaultDomainName $TenantId = [string]$_.TenantId.Guid Import-Csv .\users1.csv | foreach { $newUPN = $_.UserPrincipalName + "@" + $tenantprefix $newUPN = [string]$newUPN New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $newUPN -Password $_.Password -ForceChangePassword:$true -PasswordNeverExpires:$true -TenantId $TenantId } }