Lync PowerShell Script not working

1.1k views Asked by At

I am in process of moving users in batches from one Lync Server pool to another, this requires me to have a CSV with the user names of the one I want to move. For someone famililar with PowerShell should be able to see that I am giving it the csv file name, and then importing the file in userarray after that I want to remove the "+" symbol from the user LineURI. i.e: from tel:+5556667777 I want that to change to tel:5556667777, then I want to change the dial plan for the user and lastly I want to migrate the user from pool X to pool Y.

While it all seemingly should work, when I run the script it blanks out/erases the LineURI of the people I intend to migrate, I obviously don't know what I am missing some guidance will be appreciated.

Update: Fixed and here is how:

 $File = "C:\Location\users.csv"

 $UserArray = Import-CSV -Path $File
 $transcriptname = "F:\Transcript\Users_Logs" + `
(Get-Date -format s).Replace(":","-") +".txt"
 Start-Transcript $transcriptname

 Foreach ($user in $UserArray)
{

$Tel = Get-CSUser -Identity $user.SAMAccountName
$URI = $Tel.LineURI 
#$TelNew = $URI.Replace("tel:+", "tel:")
$TelNew = $URI.Replace("+", "")
  Get-CSUser -Identity $user.SAMAccountName
  Set-CSUser -Identity $user.SAMAccountName -LineURI $TelNew 
  Grant-CSDialPlan -Identity $user.SAMAccountName -PolicyName "New_Dial_Plan"
  Move-CsUser -Identity $user.SAMAccountName -Target new.pool.com -confirm:$false
  Get-CSUser -Identity $user.SAMAccountName
}


Stop-Transcript

The users.csv has to be in the format:

First line should have the word SAMAccountName and the subsequent lines the user ID's i.e:

SamAccountName UserID1 UserID2 UserID3...

0

There are 0 answers