Last active
November 20, 2016 13:42
-
-
Save tasgray/421611ed458302b1939cbd564431c30b to your computer and use it in GitHub Desktop.
Loop through all Office 365 delegated admin tenants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Managed Office 365 Delegated Admin Tenants.ps1 | |
# | |
# Basic connection stuff | |
$cred = Get-Credential | |
Import-Module MsOnline | |
Connect-MsolService -Credential $cred | |
# Get list of tenants & loop | |
Get-MsolPartnerContract -All | ForEach { | |
# Get all users in an office 365 tenant | |
Write-Host ("Office 365 users for " + $_.Name) | |
# Replace this with any Office 365 cmdlet you want to run | |
# Make sure you keep the -TenantId parameter | |
Get-MsolUser -TenantId $_.TenantId.Guid | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment