This script allows you to quickly inventory all your partner tenants and its users into a CSV file containing useful information such as:
- UserPrincipalName
- DisplayName
- FirstName and LastName
- Department
- Licenses (in friendly names)
- WhenCreated
- MSOnline - Connect-MsolService (MSOnline) | Microsoft Docs
- PowerShell 5.1
- Might work with previous versions, but is confirmed working on 5.1.
- Download (or copy + paste) code.ps1 to your local computer.
- Open it with PowerShell ISE, or edit it accordingly and run it directly with PowerShell.
- Edit the following:
- $PathToStoreCsv
- full path to folder to store everything in, remember a \ on the end!
- $SortCsvByDepartment (optional)
- $true/$false whether to create different csv for each deparment found
- $GetOnlyLicensedUsers (optional)
- $true/$false whether to get licensed users only or all users
- $GetSpecificTenantByDomainName (optional)
- full name of a verified domain, only retrieves users for that tenant
- $PathToStoreCsv
- Press Run Script (F5) and enter your partner account details.
- Watch the magic work!
- Automatically retrieves tenants and its users and outputs all information mentioned above to a .CSV
- Automatically sorts users by department and creates/appends a .CSV for each department with
- Inventory all tenants or one specific tenant with
- Inventory only licensed or all users