Exchange powershell help
I need to determine if a mailbox does not have their ABP set to 'student'. I've written a script to determine if they are lacking the correct AD settings to make the ABP assignment happen but I seem to have some accounts which aren't getting assigned
the correct ABP even with correct AD settings.
Here's what I'm hoping to do:
search student OU for all accounts/mailboxes which do not have ABP -eq student.
Thanks for any help.
September 14th, 2015 11:03am
What is your current script?
September 14th, 2015 11:12am
I don't have any policies in place to test with, but I'd start by getting your mailboxes with Get-Mailbox (use -OrganizationalUnit to target) and then pipe through Where-Object to test on the AddressBookPolicy attribute.
September 14th, 2015 11:19am
I'm trying this so far:
Get-Mailbox -ResultSize unlimited | where {$_.addressbookpolicy -ne "ABP-Student"}
**EDITED**
This seems to work for me: Get-Mailbox -ResultSize unlimited | where {$_.addressbookpolicy -ne "ABP-Student" -and $_.Customattribute1 eq "student"}
-
Edited by
Linux_Box
14 hours 14 minutes ago
September 14th, 2015 12:50pm
I still recommend using -OrganizationalUnit instead of getting all mailboxes, but if what you have works for you than go
September 14th, 2015 1:22pm
It doesn't like it when I use -OrganizationalUnit. It's probably a format issue but I can't find what it is expecting for OU name (i.e. what format it wants for the target OU because 'Students' doesn't work).
September 14th, 2015 2:18pm
When in doubt try using help:
Get-AdOrganizationsUnit -SearchBase <dn of out>
Help Get-AdOrganizationsUnit
September 14th, 2015 2:20pm
Still no joy. I've input the OU in every format I can find from the internet.
students
ou=students,dc=mydomain,dc=com
mydomain.com\students
It doesn't like any of them. I've tried other OUs with the same results.
September 14th, 2015 3:05pm
I generally just use the DN. Works without issue in my environment.
September 14th, 2015 3:08pm
Start by retrieving the DN of your OU and look at it. You have an issue with your typing or eyesight.
September 14th, 2015 3:12pm