Get list of users (not shared mailboxes) with or without license in Office365 using Powershell

I need a method to get all user accounts in Office365 (synced from on-prem AD with AADSync), that are NOT shared mailboxes. I also need to know if they have a license, but I already know that bit.

I need this to potentially assign them a license.

The flow:

  1. A new AD account is created on premises
  2. It is synced with AADSync to AAD/Office365
  3. A process queries AAD for users and uses custom logic to determine, if a user should get a license assigned or not. The newly created account is returned and listed as having no license
  4. Process assigns license to new account, because a business rule says so

How do I do step 3 here?

I currently use something like this:

Get-MsolUser -MaxResults Unlimited | Select-Object UserPrincipalName,IsLicensed,UsageLocation,Licenses

...But this also returns shared mailboxes, which I do not want.

0
задан 9 September 2016 в 14:31
1 ответ

Если вы предоставляете информацию об учетной записи на шаге 1, вам просто нужно запросить AAD для конкретного UPN, которое вы только что создали с помощью Get-MsolUser -UserPrincipalName user@domain, который вернет объект вместе со статусом лицензирования.

.
1
ответ дан 4 December 2019 в 16:29

Теги

Похожие вопросы