Hermans Mass enable AD users for Lync or Skype for Business

 

THis is a re-post of one of my friends in the business. Herman, I hope you are doing well. Please keep in touch and I recall our time at Ditch Witch in Oklahoma. You are a great Lync SFB resource and I hope all is well with you!!

His article is here. Mine is just a re-post of his hard work. I lose it from time to time, and so I decided to add it locally so I can find it when I need it. Enjoy!

http://hseminiano.blogspot.com/2013/03/lync-powershell-script-to-mass-enable.html

 

Of course there is always a need to mass enable users for Lync once you have Lync deployed in your environment. The easiest way to mass enable users for Lync is via a PowerShell script and a CSV file with the user information.

To enable PC-to-PC users only
Here is a script I created to mass enable users:


if ($args[0] -eq $null)
    {
    $userNameFile = read-host “Enter the full path of the .csv file with the user information.”
    $userNameFile  = $usernamefile -replace ‘”‘,””} 
else 
    {$usernamefile = $args[0]}
if ($userNameFile -ne “”) 
    {$csv=import-csv $userNameFile} 
else 
    {“Could not find a valid .csv with the user information.”
    exit}
foreach($c in $csv)
# enable for lync
{
“Enabling ” + $c.Identity + ” for Lync 2010″
Enable-csuser -identity $c.Identity -registrarpool $c.RegistrarPool –sipaddresstype $c.SipAddressType -sipdomain $c.SipDomain
}

This script will enable the users with basic PC-to-PC configuration. This script allows for organizations with multiple SIP domains and multiple pools with the columns in the .csv file for RegistrarPool and SipDomain. The .csv file will look like this:

 

1

To enable Enterprise Voice users
To enable the users for Enterprise Voice, we will make the following addition (highlighted in yellow and green) to the above script. The green highlighted section is optional if you have extensions set up in your LineURI’s like tel+12815551234;ext=1234. You can omit this section and remove the Extensions column from the .csv file if you are not using extensions in your LineURI’s:

if ($args[0] -eq $null)
    {
    $userNameFile = read-host “Enter the full path of the .csv file with the user information.”
    $userNameFile  = $usernamefile -replace ‘”‘,””} 
else 
    {$usernamefile = $args[0]}
if ($userNameFile -ne “”) 
    {$csv=import-csv $userNameFile} 
else 
    {“Could not find a valid .csv with the user information.”
    exit}
foreach($c in $csv)
# enable for lync
{
“Enabling ” + $c.Identity + ” for Lync”
$lineuri = “tel:+1” + $c.PhoneNumber + “;ext=” + $c.Extension
Enable-csuser -identity $c.Identity -registrarpool $c.RegistrarPool -sipaddresstype $c.SipAddressType -sipdomain $c.SipDomain

# Pause for 30 seconds for AD Replication
write-host -foregroundcolor Green “Pausing for 30 seconds for AD Replication”

Start-Sleep -s 30

Set-CsUser -Identity $c.Identity -enterprisevoiceenabled $True -lineuri $lineuri
Grant-CsDialPlan -Identity $c.Identity -PolicyName $c.DialPlan
Grant-CsVoicePolicy -Identity $c.Identity -PolicyName $c.VoicePolicy

}

As you can see, the script turns the 10 digit phone number into E.164 format and adds the extension (if needed) and then sets it as the LineURI for the user. The .csv file will have the following columns added for this script:

2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s