Link to home
Start Free TrialLog in
Avatar of annayeg
annayeg

asked on

Enabling Unified Messaging with a powershell script

Hi all,

I have Exchange 2010 and Unified Messaging.  I have the following script that enabled UM for list of users in a csv file.

Everything is working fine, except when we assign an extension that already is assigned to another user I don't have any error checking?  IS there an easy way to check to see if the extension is already in use?

Thanks
Anna
Avatar of SubSun
SubSun
Flag of India image

Missing script attachment?

BTB, You can find the users with specific extention using get-mailbox
Get-mailbox -Filter 'EmailAddresses -like "EUM:12345*"'
or
Get-mailbox | Where {$_.EmailAddresses -match "EUM:12345"}
Avatar of annayeg
annayeg

ASKER

HEre's what I have in my script.  Where would I check the extension?

Enable-UMMailbox -Identity $User.GUID.toString() -ummailboxpolicy $umpolicy -Extensions $mailbox.extensions  
Set-Mailbox -Identity $User.GUID.toString() -secondaryaddress $mailbox.extensions -secondarydialplan $dialplan
Write-Host $User "Successfully enabled for UM"
You can use the  'If' statement..

For example.If the value in $mailbox.extensions  is the extension number then try with..
If ($(Get-mailbox | Where {$_.EmailAddresses -match "EUM:$($mailbox.extensions)"})  -eq $null)
{Your script here}

Open in new window

Avatar of annayeg

ASKER

I've tried the get-mailbox with -filter option to expedite the process.  Here's what I am testing but it doesn't return any results:

$test = 17655:phone-context=default UM policy
get-mailbox -filter {emailaddresses -like "EUM:$($test)}

Do you know if filter can be used in this scenario?

Thanks
Are you getting result for $test = "17655"
To get result you should have an account with extn 17655 in AD, else result will be null.
Also if you can post the complete script and your sample input file then it will help..
Avatar of annayeg

ASKER

yes, I do have an account that has extn 17655 in AD but it gives nothing.
Do you think maybe the -filter option doesn't accept variables?

$test = 17655
get-mailbox -filter {emailaddresses -like  $test} |select emailaddreses

It gives me every emailaddress in the database.
I know variable in filter work with -eq but didn't check for-like, Did you try?
Get-mailbox | Where {$_.EmailAddresses -match $test}
Or Get-UMMailbox | Where {$_.Extensions -eq $test} will give you the exact match..
Avatar of annayeg

ASKER

I am looking for something that would be faster.  We have over 9000 mailboxes.
-filter seems to be faster but it doesn't seem to be working.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial