Try this.  Get-accepteddomain returns an accepteddomain object, which doesn't 
work very well for string comparisons.

$AcceptedDomains = Get-AcceptedDomain | foreach {$_.DomainName.tostring()}
foreach ($adomain in $AcceptedDomains)
{
Get-Mailbox | where {$_.PrimarySMTPAddress -like ("*" + $adomain)}
}

-----Original Message-----
From: James Bensley [mailto:jwbens...@gmail.com] 
Sent: Thursday, December 02, 2010 9:54 AM
To: MS-Exchange Admin Issues
Subject: Simple Script Question

Hi List,

This script is returning nothing:

$AcceptedDomains = Get-AcceptedDomain | select DomainName
foreach ($adomain in $AcceptedDomains)
{
Get-Mailbox | where {$_.PrimarySMTPAddress -like "*" + $adomain}
}


Where am I going wrong here? I'm stumped :(

-- 
Regards,
James.

http://www.jamesbensley.co.cc/

There are 10 kinds of people in the world; Those who understand
Vigesimal, and J others...?

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe exchangelist

**************************************************************************************************
Note: 
The information contained in this message may be privileged and confidential 
and 
protected from disclosure.  If the reader of this message is not the intended  
recipient, or an employee or agent responsible for delivering this message to  
the intended recipient, you are hereby notified that any dissemination,   
distribution or copying of this communication is strictly prohibited. If you  
have received this communication in error, please notify us immediately by  
replying to the message and deleting it from your computer. 
**************************************************************************************************



---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe exchangelist

Reply via email to