mkllpit
asked on
Exchange Powershell Script - Need to get CasMailbox for all users excluding those in a specific DL
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-DistributionGrou pMember "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
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-DistributionGrou
The last script I attempted was:
Get-ADUser -SearchBase "ou=accounts,dc=domain,dc=
and
Get-casmailbox -OrganizationalUnit "OU=accounts,dc=domain,dc=
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
ASKER
Thanks, but it still brings up the mailboxes that are listed in the $test variable.
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...
Then, enable OA for mailboxes in a specific DL...
Let me know.
Like this...
Disable OA for all mailboxes...
Get-Mailbox -ResultSize Unlimited | Set-CASMailbox -MAPIBlockOutlookRpcHttp $true
Then, enable OA for mailboxes in a specific DL...
Get-DistributionGroupMember -Identity "DISTRIBUTION_GROUP_NAME" | ForEach-Object { Set-CASMailbox -Identity $_.Name -MAPIBlockOutlookRpcHttp $false }
Let me know.
ASKER
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.
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.
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.
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks
Good luck. Again, I'm interested in what you come up with or decide.
ASKER
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.
Whatever that means, ha!
Really appreciate the assistance.
ASKER
great help
Sorry about that command. Good catch. Don't really know why I added the "foreach". It should be this instead...
Glad it worked out for you.
Get-DistributionGroupMember -Identity "DISTRIBUTION_GROUP_NAME" | Set-CASMailbox -Identity $_.Name -MAPIBlockOutlookRpcHttp $false
Glad it worked out for you.
Please try this
Open in new window