Answered by:
Import list of mailboxes and export if they are enabled

Question
-
We are moving to office 365 and unfortunately a lot of shared mailboxes were created as user mailboxes.
To migrate to office 365 we need to make them shared mailboxes so that we don't have to pay for license. We will have to disable the AD account to do this and yet we don't want to disable user mailboxes that are being used/logged into.
I need a script that will import the list of mailboxes we believe to be shared and find out which ones have enabled AD accounts. Using the following and the output is not what I expected. Any ideas? Thanks
$list = import-csv -path "C:\scripts\sharedmailboxes2.csv"
ForEach ($user in $list) {
Get-Mailbox -resultsize unlimited | where { $_.ExchangeUserAccountControl -match 'Accountenabled'}} | Select DisplayName,Alias | export-csv c:\scripts\enabledsharedmbs2.csv
Tuesday, August 9, 2016 12:26 AM
Answers
-
Okay, I see what you're doing. For each user in the list, you are getting the entire set of mailboxes in the organization. You probably want something more like this. I don't know what the CSV format is so you might need to tweak it to match the field names.
$list = import-csv -path "C:\scripts\sharedmailboxes2.csv" $DisabledMailboxes = @() ForEach ($user in $list) { $Mailbox = Get-Mailbox $user.DisplayName If ($Mailbox.ExchangeUserAccountControl -match 'Accountenabled') { $DisabledMailboxes += $Mailbox } } $DisabledMailboxes | Select DisplayName,Alias | export-csv c:\scripts\enabledsharedmbs2.csv
All of this wouldn't be necessary if you made these mailboxes shared mailboxes before establishing directory synchronization. If you do that, they'll become shared mailboxes in Exchange Online when you move them.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Celebrating 20 years of providing Exchange peer support!- Proposed as answer by Jason.ChaoModerator Wednesday, August 17, 2016 2:19 AM
- Marked as answer by Jason.ChaoModerator Friday, August 19, 2016 1:41 AM
Tuesday, August 9, 2016 10:08 PM
All replies
-
That's not all you should do. You should also change the msExchRemoteRecipientType to 100, which means remote shared mailbox.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Celebrating 20 years of providing Exchange peer support!- Proposed as answer by Jason.ChaoModerator Tuesday, August 9, 2016 7:02 AM
Tuesday, August 9, 2016 4:22 AM -
Hi ,
Agree with Ed, when an on-prem mailbox moves to the cloud the msExchRemoteRecipient type attribute need to be changed:
For more detailed information please refer to the following blog and article:
Please note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information. And the changes made in the above blog is not supported officially by Microsoft.
Hope it helps.
Best regards,
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.
Jason Chao
TechNet Community SupportTuesday, August 9, 2016 7:19 AMModerator -
I agree with you both. I am asking for help on the script. Trying to get a list of mailboxes that are are actually shared to inform them that the ad account will be disabled.
So I need this script that is not working to go out and identify from the list I pump in via CSV to find out which shared mailboxes are enabled.
Tuesday, August 9, 2016 2:45 PM -
Okay, so what is the output you are getting and how is it not what you expected? Also, what version, service pack, rollup hotfix and/or cumulative update of Exchange are you inquiring about?
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Celebrating 20 years of providing Exchange peer support!- Edited by Ed CrowleyMVP Tuesday, August 9, 2016 3:27 PM
Tuesday, August 9, 2016 3:26 PM -
Exchange 2010 SP3
the csv output is just repeating, in stead of updating for each user in the list
Tuesday, August 9, 2016 3:47 PM -
Sorry, but I can't help you if you insist on providing vague answers.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Celebrating 20 years of providing Exchange peer support!Tuesday, August 9, 2016 4:01 PM -
Please don't give up. First time asking for help. Here are the results of the csv. The output keeps repeating:
#TYPE Selected.Microsoft.Exchange.Data.Directory.Management.Mailbox
DisplayName
Alias
Database
Account, ISOrgChart
ISOrgChart
CorpDB13-App
Netcool_Alerts
netcool_alerts
CorpDB13-App
LegalDiscovery
LegalDiscovery
CorpDB07
SMEX-SAD-Discovery
SMEX-SAD-Discovery
CorpDB14
CRW_CRAWFORD_GROUP.VP.Shared
CRW_CRAWFORD_GROUP.VP.Shared
EuDB17
Account, ISOrgChart
ISOrgChart
CorpDB13-App
Netcool_Alerts
netcool_alerts
CorpDB13-App
LegalDiscovery
LegalDiscovery
CorpDB07
SMEX-SAD-Discovery
SMEX-SAD-Discovery
CorpDB14
CRW_CRAWFORD_GROUP.VP.Shared
CRW_CRAWFORD_GROUP.VP.Shared
EuDB17
Account, ISOrgChart
ISOrgChart
CorpDB13-App
Netcool_Alerts
netcool_alerts
CorpDB13-App
LegalDiscovery
LegalDiscovery
CorpDB07
SMEX-SAD-Discovery
SMEX-SAD-Discovery
CorpDB14
CRW_CRAWFORD_GROUP.VP.Shared
CRW_CRAWFORD_GROUP.VP.Shared
EuDB17
Tuesday, August 9, 2016 4:18 PM -
Okay, I see what you're doing. For each user in the list, you are getting the entire set of mailboxes in the organization. You probably want something more like this. I don't know what the CSV format is so you might need to tweak it to match the field names.
$list = import-csv -path "C:\scripts\sharedmailboxes2.csv" $DisabledMailboxes = @() ForEach ($user in $list) { $Mailbox = Get-Mailbox $user.DisplayName If ($Mailbox.ExchangeUserAccountControl -match 'Accountenabled') { $DisabledMailboxes += $Mailbox } } $DisabledMailboxes | Select DisplayName,Alias | export-csv c:\scripts\enabledsharedmbs2.csv
All of this wouldn't be necessary if you made these mailboxes shared mailboxes before establishing directory synchronization. If you do that, they'll become shared mailboxes in Exchange Online when you move them.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Celebrating 20 years of providing Exchange peer support!- Proposed as answer by Jason.ChaoModerator Wednesday, August 17, 2016 2:19 AM
- Marked as answer by Jason.ChaoModerator Friday, August 19, 2016 1:41 AM
Tuesday, August 9, 2016 10:08 PM