The Get-MsolAdministrativeUnit
cmdlet in PowerShell retrieves information about administrative units from Microsoft Office 365.
The following command gets all administrative units in the tenant of the currently authenticated user.
Get-MsolAdministrativeUnit
In this article, we will discuss how to use the Get-MsolAdministrativeUnit cmdlet to retrieve all administrative units, get an administrative unit by name, and get an administrative unit by user principal name.
Get-MsolAdministrativeUnit Syntax
The syntax of the Get-MsolAdministrativeUnit is given below.
Get-MsolAdministrativeUnit
[-UserObjectId <Guid>]
-ObjectId <Guid>
[-UserPrincipalName <String>]
[-SearchString <String>]
[-MaxResults <Int32>]
[-TenantId <Guid>]
[<CommonParameters>]
How to Get All Administrative Units in Office 365
To get all of the administrative units in Office 365 for the currently authenticated user, use the Get-MsolAdministrativeUnit cmdlet in PowerShell.
Get-MsolAdministrativeUnit
This command returns all of the administrative units from Azure Active Directory.
How to Get Administrative Unit by Name
To get an administrative unit by name, use the Get-AdministrativeUnit cmdlet with the -SearchString
parameter. The -SearchString
parameter specifies a string.
The Get-AdministrativeUnit command uses the string specified by the -SearchString
parameter to retrieve administrative units that have a display name that starts with this string.
Get-MsolAdministrativeUnit -SearchString "East Coast"
This command returns an administrative unit called “East Coast“.
PS C:\> Get-MsolAdministrativeUnit -SearchString "East Coast"
ExtensionData Description DisplayName ObjectId
------------- ----------- ----------- --------
System.Runtime.Serialization.ExtensionDataObject East Coast region East Coast e037421a-5fc2-4a7b-9b76-10afc221d8c8
How to Get Administrative Unit by User Principal Name
To get the administrative unit by user principal name, use the Get-MsolAdministrativeUnit cmdlet with the -UserPrincipalName
parameter. The -UserPrincipalName
parameter specifies a user principal name.
Get-MsolAdministrativeUnit -UserPrincipalName "[email protected]"
This command returns administrative units to which this user with the user principal name “[email protected]” belongs or is a member.
Conclusion
I hope the above article on how to use the Get-MsolAdministrativeUnit cmdlet in PowerShell to get administrative units from Office 365 is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.