How to display and Export information about office 365 users in office 365 by using powershell?

As an office 365 administrator, you would definitely need to display and export some user information such as distribution group list, all user list and mailboxes, license information and etc.
Most of those are cannot be manage from web portal or some are not convenient to manage on it.
So, the only way to do is "Powershell".
I've just collect some useful powershell command for displaying and exporting users information about office 365 users at below.



Display a list of office 365 Global Administrators
PowerShell command syntax: Get-MsolRoleMember –RoleObjectId .ObjectId | Select DisplayName,EmailAddress

For example  :Get-MsolRoleMember -RoleObjectId “Power Administrator”.ObjectId | Select DisplayName,EmailAddress

Display Different type of recipients with a specific Domain name (This is for the Administrator who need to administer more than one domain.)

Users UPN with a specific domain name suffix

PowerShell command syntax: Get-MsolUser –DomainName | ft -Property UserPrincipalName

For example  : Get-MsolUser -DomainName ictformyanmar.com | ft -Property UserPrincipalName

Display a list of user from a specific department

PowerShell command syntax: Get-msoluser | Where {$_.Department -eq ""}

For example  : Get-msoluser | Where {$_.Department -eq "Mrkt"}

Display list of services assigned to user

PowerShell command syntax: Get-msoluser -all | ForEach-Object { "============="; $_.DisplayName; $_.licenses[0].servicestatus }

Display list of users and their currently License

PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses

Export list of users and their currently License to a file

PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses < Path & File Name>

For example : Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses > c:\temp folder\Licenses.txt

Export information about office 365 users mailbox to CSV file

PowerShell command syntax: Export list of all Mailboxes Get-mailbox | Export-Csv < Path & File Name>

For example : Get-mailbox | Export-Csv c:\temp folder\allmailboxes.csv

Export list of all office 365 users
PowerShell command syntax: Get-MsolUser | select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-Csv < Path & File Name>

For example : Get-MsolUser | select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-Csv c:\temp folder\allmailboxesusage.csv

Export list of all office 365 users with License
PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv < Path & File Name>

For example : Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv c:\temp folder\userslicenses.csv

Export list of all office 365 users without License
PowerShell command syntax: Get-MsolUser -UnlicensedUsersOnly | Export-Csv < Path & File Name>

For example : Get-MsolUser -UnlicensedUsersOnly | Export-Csv c:\temp folder\userswithoutlicense.csv

Export list of all Distribution Groups
PowerShell command syntax: Get-DistributionGroup | Export-Csv < Path & File Name>

For example : Get-DistributionGroup | Export-Csv c:\temp folder\listofdg.csv

I'll write about some more powershell commands for exchange online and other useful for office 365 if I've got time.

May you all be happy.
(Be knowledgeable, pass it on then)

Post a Comment