Home

configuring URI numbers in bulk

%3CLINGO-SUB%20id%3D%22lingo-sub-461197%22%20slang%3D%22en-US%22%3Econfiguring%20URI%20numbers%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-461197%22%20slang%3D%22en-US%22%3E%3CP%3EWould%20it%20be%20possible%20to%20add%20URI%20phone%20numbers%20to%20users%20for%20direct%20routing%20in%20bulk%20via%20a%20CSV%20file...%20So%20far%20i%20am%20doing%20it%20individually%2C%201%20by%201%2C%20and%20it%20feels%20like%20i%20have%20been%20doing%20it%20forever...%20or%20am%20i%20being%20dumb....%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-461197%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-462028%22%20slang%3D%22en-US%22%3ERe%3A%20configuring%20URI%20numbers%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-462028%22%20slang%3D%22en-US%22%3E%3CP%3EPowerShell%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fdirect-routing-configure%23configure-the-phone-number-and-enable-enterprise-voice-and-voicemail%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fdirect-routing-configure%23configure-the-phone-number-and-enable-enterprise-voice-and-voicemail%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-462030%22%20slang%3D%22en-US%22%3ERe%3A%20configuring%20URI%20numbers%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-462030%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F260731%22%20target%3D%22_blank%22%3E%40WelshViking%3C%2FA%3E%20How%20are%20you%20doing%20it%3F%20Isn't%20it%20all%20by%20powerhell%20already%20%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESet-CsUser%20-Identity%20%22%26lt%3BUser%20name%26gt%3B%22%20-EnterpriseVoiceEnabled%20%24true%20-HostedVoiceMail%20%24true%20-OnPremLineURI%20tel%3A%26lt%3BE.164%20phone%20number%26gt%3B%3C%2FPRE%3E%0A%3CP%3Ein%20which%20case%20it's%20easy%20to%20read%20a%20CSV%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24users%20%3D%20Import-CSV%20-Path%20.%5Cuser.csv%3C%2FPRE%3E%0A%3CP%3Ethen%20you%20can%20loop%20through%20your%20users%20and%20set%20a%20number%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eforeach%20(%24user%20in%20%24users)%20%7B%0A%0ASet-CsUser%20-Identity%20%24user.name%20-EnterpriseVoiceEnabled%20%24true%20-HostedVoiceMail%20%24true%20-OnPremLineURI%20%24user.number%0A%0A%7D%0A%0A%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-464562%22%20slang%3D%22en-US%22%3ERe%3A%20configuring%20URI%20numbers%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-464562%22%20slang%3D%22en-US%22%3ESteven.%20Yes%20i%20am%20blundering%20through%20it%20using%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESet-CsUser%20-Identity%20%22%3CUSER%20name%3D%22%22%3E%22%20-EnterpriseVoiceEnabled%20%24true%20-HostedVoiceMail%20%24true%20-OnPremLineURI%20tel%3A%3CE.164%20phone%3D%22%22%20number%3D%22%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI%20wasn't%20aware%20of%20the%20loop%20i%20could%20use....%20is%20it%20really%20as%20simple%20as%20just%20putting%20user.number%20as%20the%20URI%20tel%3F%20That's%20so%20much%20better..%3C%2FE.164%3E%3C%2FUSER%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-464623%22%20slang%3D%22en-US%22%3ERe%3A%20configuring%20URI%20numbers%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-464623%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F260731%22%20target%3D%22_blank%22%3E%40WelshViking%3C%2FA%3E%26nbsp%3BI%20would%20suggest%20investing%20some%20time%20in%20becoming%20familiar%20in%20powershell%2C%20as%20you%20can%20see%20it's%20pretty%20easy%2C%20that's%20why%20they%20give%20it%20to%20us%20admins%20for%20scripting%20%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20command%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24users%20%3D%20Import-CSV%20-Path%20.%5Ctest.csv%3C%2FPRE%3E%0A%3CP%3Ewill%20read%20a%20CSV%20file%20(save%20from%20excel%20as%20CSV)%20from%20the%20current%20folder%20your%20powershell%20session%20is%20located.%20I'm%20saving%20this%20into%20a%20variable%20called%20%24users.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20my%20excel%20will%20have%20multiple%20lines%2C%20%24users%20becomes%20an%20array%20of%20items.%20Each%20item%20gains%20properties%20that%20are%20named%20after%20the%20first%20row%20in%20the%20CSV%2C%20my%20column%20headers.%20So%20if%20I%20have%20columns%20titled%20name%20and%20tel%20I%20would%20have%20properties%20%24user.name%20and%20%24user.tel%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20foreach%20loop%20will%20step%20through%20each%20item%20in%20the%20array%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eforeach%20(%24user%20in%20%24users)%20%7B%0A%0A%7D%3C%2FPRE%3E%0A%3CP%3EThis%20defines%20that%20each%20item%20will%20one%20be%20one%20processed%20as%20the%20%24user%20variable%20for%20all%20the%20commands%20within%20the%20%7B%7D%20section.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt's%20not%20necessary%2C%20but%20makes%20things%20easier%20to%20read%20by%20using%20%24users%20for%20the%20array%20and%20%24user%20for%20one%20item%2C%20or%20any%20other%20combination%20of%20variable%20names.%3C%2FP%3E%3C%2FLINGO-BODY%3E
WelshViking
Contributor

Would it be possible to add URI phone numbers to users for direct routing in bulk via a CSV file... So far i am doing it individually, 1 by 1, and it feels like i have been doing it forever... or am i being dumb.... 

4 Replies

@WelshViking How are you doing it? Isn't it all by powerhell already ?

 

Set-CsUser -Identity "<User name>" -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:<E.164 phone number>

in which case it's easy to read a CSV

 

$users = Import-CSV -Path .\user.csv

then you can loop through your users and set a number

 

foreach ($user in $users) {

Set-CsUser -Identity $user.name -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI $user.number

}

Steven. Yes i am blundering through it using:

Set-CsUser -Identity "<User name>" -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:<E.164 phone number>

I wasn't aware of the loop i could use.... is it really as simple as just putting user.number as the URI tel? That's so much better..

@WelshViking I would suggest investing some time in becoming familiar in powershell, as you can see it's pretty easy, that's why they give it to us admins for scripting :)

 

The command

 

$users = Import-CSV -Path .\test.csv

will read a CSV file (save from excel as CSV) from the current folder your powershell session is located. I'm saving this into a variable called $users.

 

As my excel will have multiple lines, $users becomes an array of items. Each item gains properties that are named after the first row in the CSV, my column headers. So if I have columns titled name and tel I would have properties $user.name and $user.tel

 

The foreach loop will step through each item in the array

 

foreach ($user in $users) {

}

This defines that each item will one be one processed as the $user variable for all the commands within the {} section.

 

It's not necessary, but makes things easier to read by using $users for the array and $user for one item, or any other combination of variable names.

Related Conversations