Solved

Office 365 Powershell- How to find All users with Exchange Online disabled

Posted on 2015-01-12
7
1,984 Views
Last Modified: 2015-01-14
Need a Powershell one-liner to find all users with the Exchange Online disabled
-DisabledPlans:EXCHANGE_S_STANDARD
0
Comment
Question by:K Anthony O365
  • 4
  • 3
7 Comments
 

Author Comment

by:K Anthony O365
ID: 40545284
Once found, how can I enable?
0
 
LVL 40

Expert Comment

by:Vasil Michev (MVP)
ID: 40546034
Do you mean all users that DO have license but have the Exchange plan disabled, or any user that does not have an Exchange plan enabled, regardless of other plans?
0
 

Author Comment

by:K Anthony O365
ID: 40546465
They DO have a license but the Exchange Online is disabled.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 40

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
ID: 40546543
OK, so if you insist on one-liner:

Get-MsolUser -All | ? {$_.Licenses.AccountSKUid -eq "tenant:ENTERPRISEPACK" -and ($_.CloudExchangeRecipientDisplayType -eq $null -or $_.CloudExchangeRecipientDisplayType -eq "6") } 

Open in new window


Replace the relevant SKU. The logic is to look at all the accounts that have the SKU assigned and use the CloudExchangeRecipientDisplayType to get only users without a valid mailbox (shared mailboxes are also excluded, even if they have license - the CloudExchangeRecipientDisplayType value for them is 0; UserMailbox is 1073741824)

If you want to do it a bit more detailed, I'd go for something like this:

$sku = (Get-MsolAccountSku) | ? {$_.ServiceStatus.ServicePlan.ServiceName -eq "EXCHANGE_S_STANDARD"}
$index = ($sku).ServiceStatus.ServicePlan.ServiceName.IndexOf("EXCHANGE_S_STANDARD")
Get-MsolUser -All | ? { ($_.Licenses) -and ($_.Licenses[-1].ServiceStatus[$index].Provisioningstatus -eq "Disabled") -and ($_.Licenses.AccountSkuId -eq $sku.AccountSkuId)}

Open in new window


There's still room for improvement, as it might give incomplete results if you have more than two SKUs assigned to a user (tested only with E3 and CRM ones).
0
 

Author Comment

by:K Anthony O365
ID: 40547025
Visil,

After changing the SKU in this script, nothing returned. Again, just to clarify: I have a few users with assigned SKU's but the Exchange part is unchecked (disabled). I want to find those users only.

thanks!!
0
 
LVL 40

Expert Comment

by:Vasil Michev (MVP)
ID: 40547192
The script runs fine for me, both do. Make sure you are indeed filtering only users with the correct SKU. If you are using E1 license, it will be tenant:STANDARDPACK, not tenant:ENTERPRISEPACK
0
 

Author Closing Comment

by:K Anthony O365
ID: 40548760
Thank you!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question