Forum Discussion
Jesper Stein
Jan 18, 2018Brass Contributor
Find user without mailbox
Hi. Im trying to create a script that loads users from an AD Group and filter them based on an attribute. My goal is to have a script that loads users from a group, finde the ones that do not have a ...
- Jan 18, 2018
I dont have access to AD right now, but i think you could do something like this. ! in front of $user.msExchMailboxGuid means that if the variable is null(empty), it should create a mailbox, if its already have a mailbox, a message stating this is dispalyed. Hope this works, or sett you on the right track.
$Users = Get-ADGroupMember -Identity "S_Enable_Exch2010User" | Get-ADUser -filter {msExchMailboxGuid -like "*"} foreach ($user in $users) { if(!$user.msExchMailboxGuid) { enable mailbox command } else { $user.firstname+"already have a email account." } }
VasilMichev
Jan 18, 2018MVP
Why don't you simply use the Exchange cmdlets for that? Get-Mailbox or Get-Recipient will do the tasks with ease.
And to answer the specific question about the cmdlet - you are not referencing the $users value in any way or form, thus the cmdlet runs against the whole of AD. Add it to the filter.