Enable multiple Lync user for Enterprice Voice from CSV file
Enable e few users can easily be done from Lync control panel.
But what if you have hundred or maybe thousands of users?
This script will make you life easy and perhaps a bit boring but it works :)
It reads from a csv file and outputs the results to a text file.
This is the script:
########################################################################################################
#
# A script to enable multiple users in a csv file for enterprise voice.
# Created by Kjetil LindLøkken
# http://drlync.blogspot.no/
# The script is based on this post from Scott Stubberfield and Nick Smith
# "http://blogs.technet.com/b/nexthop/archive/2010/06/10/scriptassignlineuris.aspx"
# I've added features to enable the users For Enterprice Voice and assign a Voice- and Dial Plan
# Voice Policy and DialPlan can be specified individually in the CSV file
#
########################################################################################################
param( [string] $importfile = $(Read-Host -prompt `
"Please enter a file name"))
$importedusers = Import-Csv $importfile
$transcriptname = "AssignLineUri" + (Get-Date `
-Format s).replace(":","-") +".txt"
Start-Transcript $transcriptname
foreach ($importeduser in $importedusers)
{
Set-CsUser $importeduser.SipUri -LineUri `
$importeduser.LineUri -EnterpriseVoiceEnabled $True –Verbose
Grant-CsDialPlan $importeduser.SipUri `
-PolicyName $importeduser.DialPlan -Verbose
Grant-CsVoicePolicy $importeduser.SipUri `
-PolicyName $importeduser.VoicePolicy -Verbose
}
Stop-Transcript
Copy and paste this into notepad and save as i.e. "VoiceEnableUsers.ps1" on your lync server.
Run in Lync Server management shell with administrator rights. .\VoiceEnableUsers.ps1
The script will then ask you to input the file name of you csv file i.e. users.txt
The csv file format looks like this and can be exportet from excel or similar tools:
SipUri,LineUri,DialPlan,VoicePolicy
sip:Abraham.Lincoln@Government.gov,tel:+12024561414,YourDialPlanName,YourVoicePolicyName
sip:Theodore.Roosevelt@Government.gov,tel:+12024561415,YourDialPlanName,YourVoicePolicyName
Hope this will save you some time :)
But what if you have hundred or maybe thousands of users?
This script will make you life easy and perhaps a bit boring but it works :)
It reads from a csv file and outputs the results to a text file.
This is the script:
########################################################################################################
#
# A script to enable multiple users in a csv file for enterprise voice.
# Created by Kjetil LindLøkken
# http://drlync.blogspot.no/
# The script is based on this post from Scott Stubberfield and Nick Smith
# "http://blogs.technet.com/b/nexthop/archive/2010/06/10/scriptassignlineuris.aspx"
# I've added features to enable the users For Enterprice Voice and assign a Voice- and Dial Plan
# Voice Policy and DialPlan can be specified individually in the CSV file
#
########################################################################################################
param( [string] $importfile = $(Read-Host -prompt `
"Please enter a file name"))
$importedusers = Import-Csv $importfile
$transcriptname = "AssignLineUri" + (Get-Date `
-Format s).replace(":","-") +".txt"
Start-Transcript $transcriptname
foreach ($importeduser in $importedusers)
{
Set-CsUser $importeduser.SipUri -LineUri `
$importeduser.LineUri -EnterpriseVoiceEnabled $True –Verbose
Grant-CsDialPlan $importeduser.SipUri `
-PolicyName $importeduser.DialPlan -Verbose
Grant-CsVoicePolicy $importeduser.SipUri `
-PolicyName $importeduser.VoicePolicy -Verbose
}
Stop-Transcript
Copy and paste this into notepad and save as i.e. "VoiceEnableUsers.ps1" on your lync server.
Run in Lync Server management shell with administrator rights. .\VoiceEnableUsers.ps1
The script will then ask you to input the file name of you csv file i.e. users.txt
The csv file format looks like this and can be exportet from excel or similar tools:
SipUri,LineUri,DialPlan,VoicePolicy
sip:Abraham.Lincoln@Government.gov,tel:+12024561414,YourDialPlanName,YourVoicePolicyName
sip:Theodore.Roosevelt@Government.gov,tel:+12024561415,YourDialPlanName,YourVoicePolicyName
Hope this will save you some time :)
I've just discovered that Powershell has an issue with the norwegian letters "ÆÅØ" when reading from csv file. Probably a codepage setting will fix it.
ReplyDeleteexcellent script! How about if you want to add to the lineuri the extension ie ext=1234?
ReplyDeleteHi,
DeleteIn the csv file you create you can just add ";ext=1234" to the Lineuri.
Another way (the cool way) is to add another column (Ext) in the csv file:
SipUri,LineUri,Ext,DialPlan,VoicePolicy
and then change the line in the script to
Set-CsUser $importeduser.SipUri -LineUri `
$importeduser.LineUri+";"+$importeduser.Ext -EnterpriseVoiceEnabled $True –Verbose
Script would look like this:
########################################################################################################
#
# A script to enable multiple users in a csv file for enterprise voice.
# Created by Kjetil LindLøkken
# http://drlync.blogspot.no/
# The script is based on this post from Scott Stubberfield and Nick Smith
# "http://blogs.technet.com/b/nexthop/archive/2010/06/10/scriptassignlineuris.aspx"
# I've added features to enable the users For Enterprice Voice and assign a Voice- and Dial Plan
# Voice Policy and DialPlan can be specified individually in the CSV file
#
########################################################################################################
param( [string] $importfile = $(Read-Host -prompt `
"Please enter a file name"))
$importedusers = Import-Csv $importfile
$transcriptname = "AssignLineUri" + (Get-Date `
-Format s).replace(":","-") +".txt"
Start-Transcript $transcriptname
foreach ($importeduser in $importedusers)
{
Set-CsUser $importeduser.SipUri -LineUri `
$importeduser.LineUri+";"+$importeduser.Ext -EnterpriseVoiceEnabled $True –Verbose
Grant-CsDialPlan $importeduser.SipUri `
-PolicyName $importeduser.DialPlan -Verbose
Grant-CsVoicePolicy $importeduser.SipUri `
-PolicyName $importeduser.VoicePolicy -Verbose
}
Stop-Transcript
Hope this helps you
wow that is awesome!! I'm going to give it a go. Thanks and best regards!!
Delete