get-mailbox wildcard and looping
hi.
i need to change the Exchange features of some of our users but it doesn't seem to work:
$mbx = (get-mailbox "bugs").emailaddresses | % {$_.SmtpAddress | where {$_ -like "*acme.com*"}} | Set-CASMailbox -identity $mbx -OWAEnabled $true
for whatever reason, $mbx is empty before it reaches Set-CASMailbox.
i'm also trying to use wildcard
get-mailbox *
this works but when i place ".emailaddresses" like above, it doesn't return anything.
yes i have two questions here i hope not to break then because they are related.
December 3rd, 2012 12:44pm
On Mon, 3 Dec 2012 09:44:30 +0000, Rino Mardo wrote:
>
>
>hi.
>
>i need to change the Exchange features of some of our users but it doesn't seem to work: $mbx = (get-mailbox "bugs").emailaddresses | % {$_.SmtpAddress | where {$_ -like "*acme.com*"}} | Set-CASMailbox -identity $mbx -OWAEnabled $true
>
>
>
>for whatever reason, $mbx is empty before it reaches Set-CASMailbox.
$mbx is an array of objects of different classes
(Microsoft.Exchange.Data.X400ProxyAddress,
Microsoft.Exchange.Data.SmtpProxyAddress, etc.). The -Identity
parameter of the set-casmailbox accepts pipeline input, so you should
be able to remove the "-Identity $mbx" from the cmdlet.
>i'm also trying to use wildcard get-mailbox *
>
>this works but when i place ".emailaddresses" like above, it doesn't return anything.
That's because the array you've filled with mailbox objects doesn't
have a property name "emailaddresses". Each element of the array has
that property, though. You don't need the "*", either.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 4th, 2012 5:50am
Hi
Do you mean by set those mailbox's OWAEnable to True, the condition is their smtp address containing
"*acme.com*"
Is that right?
If yes, please try
Get-Mailbox -resultsize unlimited | where{$_.Emailaddresses -like "*acme.com*"} | Set-CASMailbox -OWAEnabled $True
Cheers
If you have any feedback on our support, please click
here
Zi Feng
TechNet Community Support
December 4th, 2012 11:06am
thanks guys. i'll try them as soon as get back to office.
Free Windows Admin Tool Kit Click here and download it now
December 4th, 2012 11:50am
it worked!! :)
thanks Zi.
December 4th, 2012 12:25pm
thanks Rich for the explanation.
Free Windows Admin Tool Kit Click here and download it now
December 4th, 2012 12:25pm