Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Exchange Powershell Script - Need to get CasMailbox for all users excluding those in a specific DL

Posted on 2016-10-06
12
98 Views
Last Modified: 2016-10-07
I need to Get, then ultimately Set the MapiBlockOutlookRpcHttp for All users except for those in a specific Distribution List.

I've tried many different variations and they all start of with creating a String variable to get the members of that DL:

$test=Get-DistributionGroupMember "Group A"

The last script I attempted was:

Get-ADUser -SearchBase "ou=accounts,dc=domain,dc=com" -filter {Name -notlike $test } | select name

and

Get-casmailbox -OrganizationalUnit "OU=accounts,dc=domain,dc=com" | where{$_.Name -ne $test}

I've tried every variation with and without single/double quotes. It does work if I input a specific user Name, but not with the String Variable.

Any help would be greatly appreciated.

Thanks
0
Comment
Question by:mkllpit
  • 6
  • 5
12 Comments
 
LVL 25

Expert Comment

by:-MAS
ID: 41832556
Hi,
Please try this
Get-mailbox -OrganizationalUnit "ou=accounts,dc=domain,dc=com" | where {$_.name -ne "test"}

Open in new window

0
 

Author Comment

by:mkllpit
ID: 41832604
Thanks, but it still brings up the mailboxes that are listed in the $test variable.
0
 
LVL 15

Expert Comment

by:Todd Nelson
ID: 41832623
Wouldn't it be easier to block OA for all mailboxes (set the MAPIBlockOutlookRpcHttp value to $true) and then disable OA for those in the specific DL (set the MAPIBlockOutlookRpcHttp value to $false)?

Like this...

Disable OA for all mailboxes...

Get-Mailbox -ResultSize Unlimited | Set-CASMailbox -MAPIBlockOutlookRpcHttp $true

Open in new window


Then, enable OA for mailboxes in a specific DL...

Get-DistributionGroupMember -Identity "DISTRIBUTION_GROUP_NAME" | ForEach-Object { Set-CASMailbox -Identity $_.Name -MAPIBlockOutlookRpcHttp $false }

Open in new window


Let me know.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:mkllpit
ID: 41832626
Thanks, I've thought of that and agree it would probably work. This has now become a grudge against Exchange, I want to figure out how to do this.
0
 
LVL 15

Expert Comment

by:Todd Nelson
ID: 41832631
It does work.  I just ran it in my test environment.

Don't spin your wheels for too long.  But I would be interested to see what combination of commands that you come up with if you accomplish it.
0
 

Author Comment

by:mkllpit
ID: 41832643
Thanks for testing. Ideally I would like to have a command to be 100% unobtrusive to the end-users, rather than disable then re-enable. I'll see what I can come up with and post it.
0
 
LVL 15

Accepted Solution

by:
Todd Nelson earned 500 total points
ID: 41832647
If you want it to be unobtrusive, export your list of mailboxes to a CSV, remove those mailboxes from the CSV you don't want affected, and then run the command to set the value you want using the CSV.

Export mailbox names to CSV...

Get-Mailbox | Select-Object name | Export-Csv "C:\Mailboxes.csv" -NoTypeInformation

Open in new window


Remove names from list that exist in specific DL

Then disable OA for specific list of users...

Import-Csv "C:\Mailboxes.csv" | ForEach-Object { Set-CASMailbox -Identity $_.Name -MAPIBlockOutlookRpcHttp $false }

Open in new window


You now have 2 viable options.

Let me know.
0
 

Author Comment

by:mkllpit
ID: 41832652
Ah, great solution. I'm gonna hold that as my backup if I can't figure the alternative out before the end of today.
Thanks
0
 
LVL 15

Expert Comment

by:Todd Nelson
ID: 41832655
Good luck.  Again, I'm interested in what you come up with or decide.
0
 

Author Comment

by:mkllpit
ID: 41833813
I'm going with your first suggestion, thanks again. Just an FYI, need to remove the foreach-object, this is because it's already piping and the foreach command essentially pipes again.

Whatever that means, ha!

Really appreciate the assistance.
0
 

Author Closing Comment

by:mkllpit
ID: 41833814
great help
0
 
LVL 15

Expert Comment

by:Todd Nelson
ID: 41833828
Sorry about that command.  Good catch.  Don't really know why I added the "foreach".  It should be this instead...

Get-DistributionGroupMember -Identity "DISTRIBUTION_GROUP_NAME" | Set-CASMailbox -Identity $_.Name -MAPIBlockOutlookRpcHttp $false

Open in new window


Glad it worked out for you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

792 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