Thursday, August 9, 2012

Enabling users for Lync Enterprise Voice

I am now piloting Lync Enterprise Voice for my company, and we will be enabling many users moving forward. I have written the following script to:
  1. Move users to a "Branch" Pool
  2. Enable them for Voice
  3. Grant a voice policy
The script is meant to be run, eventually, by local IT at the branch location. It takes input from a .csv file structured like:

LineURI,Name,ADUSERNAME
tel:+11112345678;ext=5678,Jon Smith,jsmith
tel:+11112347485;ext=7485,Nasir Patel,npatel
tel:+11112347518;ext=7518,Tom Jones,tjones


You can tailor the LineURI as appropriate for your organization.

The script, when launched, asks for the target pool, the file with the information and the voice policy to be granted:




That's all you need to do. Well, that and then enable them in whatever voicemail solution you are employing...

The code is as follows. I will make it more elegant as time allows.

<# 
.SYNOPSIS 
  Queries admin for Pool, Input File and Voice Policy for the users. Then
  reads info in Input file, moves users to appropriate pool, enables Enterprise
  Voice for them, and grants the entered Voice Policy.

.NOTES 
    Version           : 1

      Lync Version  : 2010 through CU6
    Author(s)      : Sean William McNamara (
sean.mcnamara@spx.com)
    Dedicated Post  :
http://unicomsta.blogspot.com/
    Disclaimer     : Test thoroughly and use at your own risk. If you don't test it, and you break stuff, it isn't MY fault.
   
.LINK 
    http://unicomsta.blogspot.com/2012/08/enabling-users-for-lync-enterprise-voice.html

.EXAMPLE
  .\Enable-EvUsers.ps1
#>
#initialize variables
$poolfqdn = read-host "Enter new pool FQDN to move users to "
$InputFileName = read-host "Enter filename for user data "
$VoicePolicy = read-host "Enter Voice Policy Name "


#read data for Accounts
$AccountData = Import-Csv $InputFileName

#move users to correct registrar pool
foreach ($item in $AccountData)
{ write-host -fore yellow "Moving" $item.NAME "... "
  move-csuser -identity $item.ADUSERNAME -target $poolfqdn -confirm:$false
}

write-host
write-host -fore green "Move completed"
write-host
#enable EV and set URI

foreach ($item in $AccountData)
{ write-host -fore yellow "Enabling Voice for " $item.NAME "... "
  Set-CsUser -Identity $item.adusername -EnterpriseVoiceEnabled $true -LineURI $item.LineURI
}

write-host
write-host -fore green "Enterprise Voice Enabled"
write-host

#grant Voice Policy
foreach ($item in $AccountData)
{ write-host -fore yellow "Granting Voice Policy "$VoicePolicy" to " $item.NAME " ... "
  Grant-CsVoicePolicy -Identity $item.adusername -PolicyName $VoicePolicy
}

write-host
write-host -fore green "Voice Policies Granted"
write-host

2 comments:

Thanks for reading and commenting. I look forward to it.