Pages

Tuesday, November 22, 2011

How to enable lync rcc users from Excel

How to enable lync rcc users from Excel

I collect data of the users that are gonna be enabled to a xlsx file.
The data should be
$SamAccountName
$mail #this will be the sip address
$telephoneNumber
$email: is just a copy of $mail. minus the domain. this is for creating the rcc connection

So i create the csv file to and run this script

Import-Module ActiveDirectory

Import-Module Lync

$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $True
$objWorkbook = $objExcel.Workbooks.Open("C:\Scripts\NewUsers.xlsx")


$row = 2

do
    {
        $SamAccountName = $objExcel.Cells.Item($row,1).Value()
        $mail = $objExcel.Cells.Item($row,2).Value()
        $telephoneNumber = $objExcel.Cells.Item($row,3).Value()
$email = $objExcel.Cells.Item($row,4).Value()
        Enable-CsUser -Identity $SamAccountName -RegistrarPool "Your lync pool" -SipAddress "sip:$email" | Set-CsUser -RemoteCallControlTelephonyEnabled $true -LineServerURI "sip:$mail@Change this to the rcc fqdn" -LineURI "tel:$telephoneNumber;phone-context=dialstring"
        $row++
    }
until ($SamAccountName -eq $Null)


$objExcel.Quit()

$Null = & {
    [Runtime.Interopservices.Marshal]::ReleaseComObject($objExcel)
    [Runtime.Interopservices.Marshal]::ReleaseComObject($objWorkbook)
    }

[GC]::Collect()


Thanks for the view

Niclas Strøm

No comments:

Post a Comment