Proposed Analog Phone as a member of Response Group

  • Mittwoch, 16. März 2011 10:35
     
     

    Dear Community,

    I Have Lync Server 2010 deployment integrated with legacy PBX  via Audiocodes MP voice gateway, which configured as AnalogPhone lync account (with own Tel: and SIP URI).

    All incoming calls routed to Lync IVR, and i need my Lagacy PBX to be a part of default Response Group.

    How can I acomplish this task?


    MCITP: EA, EMA, VA;

Alle Antworten

  • Donnerstag, 17. März 2011 07:21
     
     

    You can't. Even if you create a Lync user, add it to response group and set it's telephony settings to forward to a legacy pbx extension, Response Groups will not forward the call by design. You can only add Lync-enabled users to response group agent groups.

    The only way you can do this is configure a timeout or overflow action on a queue and forward it to a specific tel URI, which would reside on the legacy PBX. But this only allows including one legacy pbx extension (not multiple agents) and there is no follow-up if the call is not answered since Response Groups is no longer managing the call


    Technical Specialist Microsoft OCS/Lync & UC Voice Specialisation - http://www.uwictpartner.be
    If you think my post is the answer to your question, please mark it as answer so future visitors can easily find it.
  • Donnerstag, 17. März 2011 07:46
     
     

    Thank you, Ruben!

    This is very sad and means Lync cannot be integrated with legacy telephony system as was expected and promised by Microsoft.

    Now it's seems I have to shift all incoming call routing back to legacy PBX, and handle IVR, groups end queues by Asterisk.


    MCITP: EA, EMA, VA; MCSA
  • Freitag, 18. März 2011 13:46
    Moderator
     
     

    There is a workaround - let me ping the guy who found it so he can post the details.


    Mike Stacy | http://mikestacy.typepad.com
  • Montag, 21. März 2011 07:42
     
     

    It would be fantastic, if it's true!


    MCITP: EA, EMA, VA; MCSA
  • Montag, 21. März 2011 13:47
    Moderator
     
     

    Credit for this goes to John Lamb and the folks at Modality Systems for this.  Here is the solution they came up with:

    We setup the analog phone contact with a PIN, then “logged in” as the analog device contact (using the extension + PIN) from a Lync phone.  Once we did this, we can add the analog device to the list of delegates.  Even if the analog device user is logged out of the phone, it stays in the list of delegates and the phone extension will ring when the main branch user is called.


    Mike Stacy | http://mikestacy.typepad.com
  • Montag, 21. März 2011 14:45
     
     
    Looks like a trick, but i don't have common area phone (as you mean Lync Phone), a have CX700 which don't support pin authentication. How can I log as AnalogDevice?
    MCITP: EA, EMA, VA; MCSA
  • Montag, 21. März 2011 14:46
     
     
    May be some option changes on ad contact object when AnalogDevice logged, may be I can edit it manually?
    MCITP: EA, EMA, VA; MCSA
  • Montag, 21. März 2011 14:51
    Moderator
     
     

    The only way to do a full ext/PIN logon with with a Lync Phone Edition device.  There is a test-csphonebootstrap cmdlet but I'm not sure it will perform a full registration.  Even if it does, it unregisters as soon as the test process is complete so it wouldn't help you with this.


    Mike Stacy | http://mikestacy.typepad.com
  • Montag, 21. März 2011 17:35
     
     

    I've found a way to add AnalogDevice sip uri as response group member:

    1. Create User object in AD, for example "t913"

    2. Open Attribute Editor, copy distinguishedName value (CN=t913,OU=LyncContacts,DC=company,DC=local)

    3. from Lync shell execute

    New-CsAnalogDevice -LineUri tel:+913 -SipAddress "sip:t913@company.com" -DisplayName "t913" -RegistrarPool lync.compamy.local -AnalogFax $False -Gateway dv-vgate1.company.local -DN "CN=t913,OU=LyncContacts,DC=company,DC=local"

    4. make shure Get-CsAnalogDevice displays added AnalogDevice

    5. In Attribute Editor, clear "msRTCSIP-ApplicationOptions"=8 value

    6. from Lync shell execute Update-CsUserDatabase

    make shure Get-CsAnalogDevice not displays added AnalogDevice

    7.

    $x = Get-CsRgsAgentGroup -name "test"
    $x.AgentsByUri.Add("sip:t913@company.com")
    Set-CsRgsAgentGroup $x

    If there's no error, account was added to Response group. make shure by exec Get-CsRgsAgentGroup -name "test"

    8. In Attribute Editor, restore "msRTCSIP-ApplicationOptions"=8

    9. execute Update-CsUserDatabase

    10. check if it works


    MCITP: EA, EMA, VA; MCSA
  • Dienstag, 22. März 2011 06:31
     
     

    10. Checked, not AnalogDevice not ring.

    Can you please compare AD Account attributes befere "PIN" login an after?


    MCITP: EA, EMA, VA; MCSA
  • Montag, 11. April 2011 13:58
     
     
    I'm still serching for workaround!
    MCITP: EA, EMA, VA; MCSA
  • Montag, 19. September 2011 16:03
     
     

    I have access to a Lync phone and need to put an analog device into a response group (night bell on a paging system). Can someone tell me how to set the PIN on the analog contact so I can log in?

    Thanks!

    Bill

  • Dienstag, 20. September 2011 04:53
     
     
    Set-CsClientPin
    MCITP: EA, EMA, LSA, VA; MCSA
  • Dienstag, 20. September 2011 13:04
     
     

    OK, I got the pin set and was able to add the analog contact as a delegate, but I still can't seem to add it as an agent in the response group. I need to be able to ring it as part of the group and I don't think the delegate will work as the RG doesn't follow the call forwarding settings.

    Has anyone be able to make this work?

  • Mittwoch, 7. Dezember 2011 19:08
     
     

    Argon.pro - Have you been able to come up with a solutions to this madness?  I too am trying differernt things to get our nightbell to work like it should.

     

    Thanks

    B.C.


    Brent_c76
  • Mittwoch, 7. Dezember 2011 19:23
     
     

    I ended up creating a user called "night bell" and then created a team call group from within that user that includes the analog contact that rings the prot on the gateway.

    The only problem is that the longest you can set a user to ring before forwarding somewhere else is 60 seconds. So I set it to forward to a response group that rings a group of phones for another 60 seconds and then it forwards back to the user with the team call again for another 60.

  • Mittwoch, 14. Dezember 2011 22:14
     
     

    I tried to do as you suggested, and I could not get this to work properly.  If I create a user in AD, i am unsure how to convert it to an Analog user.  If I create an Analog user via PS, It created it as a Contact and not a User, therefore I am unable to add it to the team call group.  I can call teh port on the gateway if i dial the extension from an internal phone, but when i call from an outside line, and i ring my response group, the analog line does not ring over the PA.  I am sure this can be done, I know I am not the only one that has come across this....

     

    any pointers would be appreciated.

     

    Thanks.

    B.C.


    Brent_c76
  • Mittwoch, 14. Dezember 2011 22:52
     
     

    B.C.

    Here are the steps

    Create new analog device :

    New-CsAnalogDevice -LineUri tel:+913 -SipAddress "sip:t913@company.com" -DisplayName "t913" -RegistrarPool lync.compamy.local -AnalogFax $False -Gateway dv-vgate1.company.local -DN "CN=t913,OU=LyncContacts,DC=company,DC=local"

    Verify that you can call the number for the analog device and ring the "night bell" on the paging system

    Set conference pin for the analog device using set-csclientpin

    Log in as that user on a Lync phone edition phone

    Then you should be able to add the user to a team call group of another regular Lync user

    Add any other users or phones that you want to ring along with the "night bell" to the team call group

    Set your outside number to ring the user with the team call group

    As stated above the only problem with this is the longest you can ring the user with the team call group is 60 seconds. What I did was set the team call user to forward to a Response group after 60 seconds which then rings the same users and phones without the analog device (again an analog device cannot be an agent in the response group) for another 60 seconds and then forwarded the response group back to the team call user for another 60 seconds.

    The result is 60 seconds of overhead ringing with a group of users and phones, then 60 seconds of just users and phones, and then another 60 seconds of overhead with users and phones.

    not a great solution but met my clients needs

    BTW, if you put the user with the team call in a response group, the team call will not work. Any call forwarding options are not followed for a call to an agent in a response group (by design)

    hope that helps!

    Bill

  • Mittwoch, 30. Mai 2012 06:24
     
     

    OK, I followed Argon's instructions and was able to add an analog device as a member of a response group. I call the response group and the cordless phone I added rings along with the all the other Lync users. Success!

    Unfortunately, that only seems to last until the first time the Response Group service is restarted. About a minute after the service starts it appears to run a sanity check and notices that the analog device user isn't a normal Lync-enabled user, so it stops routing calls to it.

    In the event log on the Lync server I get warnings with Event ID 31137 and 31138 from the source "LS Response Group Service". The body of two events are:

    During the Active Directory update non-SIP enabled agents were found.

    The following users are specified as agents, but are not SIP enabled:

    sip:it.cordless@AccessCapitalAdvisers.com.au

    And

    During the Active Directory update non-UC enabled agents were found.

    The following users are specified as agents, but are not UC enabled:

    sip:it.cordless@AccessCapitalAdvisers.com.au

    I've also tried the Modality Solutions suggestion of adding a PIN and logging in on a CX600 using extension and PIN. Doesn't seem to change anything.

    I really want to have a cheap cordless phone plugged into an FXS port on my NET UX1000 act as part of our IT Support response group. We're a small team and I want the flexibility of being able to take the "IT phones" with me when I go to make a coffee if I happen to be the only one in the office.

    We're also looking at Polycom Spectralink 8440 WiFi handsets running their UC firmware as native Lync clients, but that's an expensive solution. I've looked at the Snom M9 as well, but they still seem to be a steaming pile of instability and feature incompleteness.

    So for the moment, I'm stuck. I really hope this gets added as an officially supported feature at some point. Having it in the next CU would be awesome, but I'm not really expecting to see it before the Wave 15 release.

  • Dienstag, 26. Februar 2013 14:15
     
     
    I digged around with this issue the last two days and found an additional point, which is needed to get this working.

    I think Access Capital is right with the fact, that the RGS sanity check notices and removes the workaround. But more to this part later.

    Argon.pro noticed, that the analog device didn't ring with the other devices after he did the steps. It is possible that he tried to add the "analog device" to a agent group with the "parallel" routing mode.

    The problem with this:
    The parallel routing mode checks the availability of the users in the agent group so that the call is only routed to available (green) agents, not routed to users which are busy (red), away(yellow) or already in a call (busy, red).
    And the analog device has "no status" (grey, offline) because it is only a contact object.

    The workaround for this issue is the following:
    Use the attendant routing mode if you need analog devices in response groups.
    It looks like the attendant routing mode doesn't check the availability of the agents (since it wouldn't be possible to "see" more waiting calls in the attendant client then, because the agent which uses the attendant client is already in a call).
    But be careful - if you do it in that way, you need to know that the other incoming calls will ring also at all other agents in the agent group!

    So for this workaround step by step:

    HINT: Remember that the Lync Server as well as the Active Directory may take some time after every step until the changes are synced.




    (0. If redoing - remove everything again first and pause a bit.)

    1. Create a User object in AD, for example "t913"

    2. Open Attribute Editor, copy the value of "distinguishedName" [for example (CN=t913,OU=LyncContacts,DC=company,DC=local)]

    3. From Lync shell execute
    New-CsAnalogDevice -LineUri tel:+913 -SipAddress "sip:t913@company.com" -DisplayName "t913" -RegistrarPool lync.compamy.local -AnalogFax $False -Gateway dv-vgate1.company.local -DN "CN=t913,OU=LyncContacts,DC=company,DC=local"

    4. Pause 15 seconds.

    5. Make sure Get-CsAnalogDevice displays the added AnalogDevice

    6. In Attribute Editor, clear "msRTCSIP-ApplicationOptions"=8 value

    7. Wait 5 seconds

    8. From Lync shell execute Update-CsUserDatabase

    9. Wait 60 seconds

    10. Make sure Get-CsAnalogDevice does not display added AnalogDevice anymore

    11. Add the AnalogDevice to the AgentGroup AND change the AgentGroup routing method to "Attendant"

    $x = Get-CsRgsAgentGroup -name "test"
    $x.AgentsByUri.Add("sip:t913@company.com")
    $x.RoutingMethod = "Attendant"
    Set-CsRgsAgentGroup $x

    If there's no error, account was added to the Response group and the RoutingMethod is changed to Attendant.

    12. Pause 5 seconds

    13. Verify both by

    Get-CsRgsAgentGroup -name "test"

    14. In Attribute Editor, restore "msRTCSIP-ApplicationOptions"=8

    15. Execute Update-CsUserDatabase (two times to be sure)

    16. Pause 120/180 seconds (worst case 5 minutes)

    17. Check if it works.



    If we remember the problem, that the RGS sanity check removes this workaround, I developed a small script which does this for us. Ill just post it here as well.

    Finally - I think that's all whats possible for that issue.

    If you want to undo the changes, just do the script until the end of the part
    # Delete everything for a new startover

    ############################################
    #
    # Add-LyncAnalogPhone_to_RGS.ps1
    #
    # Written for Lync 2010 on Windows Server 2008 R2

    # Create protocol path
    $scriptname = $myinvocation.mycommand.name
    if (!(Test-Path C:\install)) {New-Item C:\install -type directory}
    if (!(Test-Path C:\install\scripts)) {New-Item C:\install\scripts -type directory}
    if (!(Test-Path C:\install\scripts\logs)) {New-Item C:\install\scripts\logs -type directory}
    if (!(Test-Path C:\install\scripts\logs\$scriptname)) {New-Item C:\install\scripts\logs\$scriptname -type directory}

    $date = Get-Date
    # Start protocol
    Start-Transcript ("C:\install\Scripts\logs\$scriptname\"+$date.Day+"_"+$date.Month+"_"+$date.Year+"___"+$date.Hour+"_"+$date.Minute+".log")

    # Import both needed Modules
    Import-Module ActiveDirectory
    Import-Module Lync

    ########################################################
    # vars EDIT HERE
    ########################################################
    $number = "913"  #number of analog phone
    $device = "t"+$number #name for User in AD + Lync
    $displayName = "Analog 913 (mobile)"  #name of the device
    $password = ConvertTo-SecureString -String "Passw0rd!" -AsPlainText -Force #Passwort for created User
    $RegistrarPool = "lync.compamy.local" #Lync RegistrarPool
    $Gateway = "dv-vgate1.company.local"  #Gateway for the device, could also be the PSTN-Gateway
    $UPN_End = "@company.com"  #User-Domain for UPN-Creation; also possible @subdomain.company.com
    $SIP_Domain = "@company.com" #SIP-Domain
    $RGS_Agent_Group = "test"  #Agent-Group-Name
    $RoutingMethod_old = "Parallel"  #standard Routing Method
    $RoutingMethod_new = "Attendant"  #needed Routing Method
    ########################################################
    # DO NOT EDIT after here.
    ########################################################

    # Delete everything for a new startover
    Remove-ADUser $device -Confirm:$false

    Update-CsUserDatabase

    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Remove("sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_old
    Set-CsRgsAgentGroup $x

    Update-CsUserDatabase

    ###########################################################
    Start-Sleep 20

    # Create a User in AD
    New-ADUser $device
    Set-ADUser $device -UserPrincipalName (""+$device+$UPN_End)
    Set-ADAccountPassword $device -Reset -NewPassword $password
    Set-ADUser $device -Enabled 1

    # Copy distinguished Name
    $DN = (Get-ADUser $device).distinguishedName

    # Lync: Add Analog Device
    New-CsAnalogDevice -LineUri ("tel:+"+$number) -SipAddress ("sip:"+$device+$SIP_Domain) -DisplayName $displayName -RegistrarPool $RegistrarPool -AnalogFax $false -Gateway $Gateway -DN $DN

    # Make sure, that the AnalogDevice is added.
    Start-Sleep 15

    Get-CsAnalogDevice

    # In Attribute Editor, clear "msRTCSIP-ApplicationOptions"=8 value
    Set-ADUser $device -Clear msRTCSIP-ApplicationOptions

    # Update User Database
    Start-Sleep 5

    Update-CsUserDatabase

    # The Analog device should not be displayed anymore

    Start-Sleep 60

    Get-CsAnalogDevice

    # Add the "User" to RGS and change the routing method.
    Get-CsRgsAgentGroup -name $RGS_Agent_Group |foreach {$_.AgentsByUri} |foreach {$_.AbsoluteUri}

    Start-Sleep 5

    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Insert(0, "sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_New
    Set-CsRgsAgentGroup $x

    Start-Sleep 5

    Get-CsRgsAgentGroup -name $RGS_Agent_Group |foreach {$_.AgentsByUri} |foreach {$_.AbsoluteUri}

    # In Attribute Editor, restore "msRTCSIP-ApplicationOptions"=8
    Set-ADUser $device -Add @{"msRTCSIP-ApplicationOptions"=8}

    # Update User-DB
    Update-CsUserDatabase
    Start-Sleep 10
    Update-CsUserDatabase

    Start-Sleep 180
    Write-Output "|$device| was added to |$RGS_Agent_Group| and the routing method was changed to |$RoutingMethod_new| !"

    Stop-Transcript
    #####################################
  • Mittwoch, 15. Mai 2013 07:52
     
     Vorgeschlagene Antwort Enthält Code

    Hello again!

    Conclusion:

    - This is not a feature and maybe it will never be a feature.

    - There is a workaround which can add an analog phone for at least until the next health check

    - I developed a script (two scripts) which can be used to add a device and remove the device again.

    Since the script failed "sometimes" i reworked it in a better way. Maybe to code is not that nice, but it works contineously.

    Add-LyncAnalogPhone_913_to_test.ps1

    $scriptname = $myinvocation.mycommand.name
    if (!(Test-Path C:\install)) {New-Item C:\install -type directory}
    if (!(Test-Path C:\install\scripts)) {New-Item C:\install\scripts -type directory}
    if (!(Test-Path C:\install\scripts\logs)) {New-Item C:\install\scripts\logs -type directory}
    if (!(Test-Path C:\install\scripts\logs\$scriptname)) {New-Item C:\install\scripts\logs\$scriptname -type directory}
    
    $date = Get-Date
    Start-Transcript ("C:\install\Scripts\logs\$scriptname\\" +$date.Day+ "_" +$date.Month+ "_" +$date.Year+ "___" +$date.Hour+ "_" +$date.Minute+ ".log")
    
    Import-Module ActiveDirectory
    Import-Module Lync
    
    ########################################################
    # vars EDIT HERE
    ########################################################
    $number = "913" #number of analog phone
    $device = "t"+$number #name for User in AD + Lync
    $displayName = "Analog 913 (mobile)"  #name of the device
    $password = ConvertTo-SecureString -String "Passw0rd!" -AsPlainText -Force #Passwort for created User
    $RegistrarPool = "lync.company.local" #Lync RegistrarPool
    $Gateway = "dv-vgae1.company.local" #Gateway for the device, could also be the PSTN-Gateway
    $UPN_End = "@company.com" #User-Domain for UPN-Creation; also possible @subdomain.company.com
    $SIP_Domain = "@company.de" #SIP-Domain
    $RGS_Agent_Group = "test" #Agent-Group-Name
    $RoutingMethod_old = "Parallel"  #standard Routing Method
    $RoutingMethod_new = "Attendant" #needed Routing Method
    
    ########################################################
    # DO NOT EDIT after here.
    ########################################################
    
    Write-Verbose "Number: $number" -Verbose
    Write-Verbose "Device: $device" -Verbose
    Write-Verbose "Display Name: $displayName" -Verbose
    Write-Verbose "Password: $password" -Verbose
    Write-Verbose "Pool: $RegistrarPool" -Verbose
    Write-Verbose "Gateway: $Gateway" -Verbose
    Write-Verbose "UPN: $UPN_End" -Verbose
    Write-Verbose "SIP: $SIP_Domain" -Verbose
    Write-Verbose "AgentGroup: $RGS_Agent_Group" -Verbose
    Write-Verbose "Routing OLD: $RoutingMethod_old" -Verbose
    Write-Verbose "Routing NEW: $RoutingMethod_new" -Verbose
    Write-Verbose "" -Verbose
    Write-Verbose "" -Verbose
    
    #0. Delete everything for a new startover
    Remove-ADUser $device -Confirm:$false
    Write-Verbose "Removed $device from the AD." -Verbose
    
    Update-CsUserDatabase
    
    
    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Remove("sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_old
    Set-CsRgsAgentGroup $x
    Write-Verbose "Agent-Group was set to the old settings." -Verbose
    
    
    Update-CsUserDatabase
    Start-Sleep 2
    ###########################################################
    
    #1. Create a User in AD
    
    New-ADUser $device
        Write-Verbose "AD-User $device was added." -Verbose
      Set-ADUser $device -UserPrincipalName (""+$device+$UPN_End)
        Write-Verbose "UPN of $device was set." -Verbose
      Set-ADAccountPassword $device -Reset -NewPassword $password
        Write-Verbose "Passwort of $device was set." -Verbose
      Set-ADUser $device -Enabled 1
        Write-Verbose "Activation of $device is done." -Verbose
    
    
    #2. Copy distinguished Name
    #Start-Sleep 5
    $repeat1 = $false
    
    do {
      Start-Sleep 2
      $DN = (Get-ADUser $device).distinguishedName
      Write-Verbose "DN of $device is: $DN" -Verbose
      if (-not ($DN -eq ((Get-ADUser $device).distinguishedName) -and ($DN -ne $null))) {
        $repeat1 = $true
      }
      } while ($repeat1)
    
    #3. Lync: Execute
    $onetime = $true
    
    do {
      
      $repeat2 = $true
    
      if (-not ((Get-CsAnalogDevice) -eq $null)){
        $DevIsSet = Get-CsAnalogDevice |where {$_.Name.Contains("$device")}
      } else {
      $DevIsSet = $false
      }
    
      if ((-not $DevIsSet) -or ($DevIsSet -eq $null)) {
        Write-Verbose "AnalogDevice $device is not created up to now, creating..." -Verbose
        Start-Sleep 1
        
        if ($onetime -eq $true) {
          New-CsAnalogDevice -LineUri ("tel:+"+$number) -SipAddress ("sip:"+$device+$SIP_Domain) -DisplayName $displayName -RegistrarPool $RegistrarPool -AnalogFax $false -Gateway $Gateway -DN $DN
        }
    
        $onetime = $false
        $repeat2 = $true
            
      } else {$repeat2 = $false; Write-Verbose "AnalogDevice $device was created" -Verbose}
    } while ($repeat2)
    
    #4. Make sure, that the Analog device is added.
    #tart-Sleep 15
    #
    #Get-CsAnalogDevice
    #
    
    #5. In Attribute Editor, clear "msRTCSIP-ApplicationOptions"=8 value
    Set-ADUser $device -Clear msRTCSIP-ApplicationOptions
    Write-Verbose "$device is changed to an agent." -Verbose
    
    #6. from Lync shell execute
    #Start-Sleep 5
    
    Update-CsUserDatabase
    
    # should not display anymore
    
    #Start-Sleep 60
    $i = 1;
    #onetime2 = $true
    do {
      
      $repeat3 = $true
    
      if (-not ((Get-CsAnalogDevice) -eq $null)){
        $DevIsSet = Get-CsAnalogDevice |where {$_.Name.Contains("$device")}
      } else {
      $DevIsSet = $false
      }
    
      if ((-not $DevIsSet) -or ($DevIsSet -eq $null)) {
        Write-Verbose ('AnalogDevice '+$device+' is an "Agent" right now.') -Verbose
        Start-Sleep 1
        
        #$onetime2 = $false
        $repeat3 = $true
            
      } else {$repeat3 = $false; Write-Verbose ('AnalogDevice '+$device+' is not "unregistered". '+$i) -Verbose; Set-ADUser $device -Clear msRTCSIP-ApplicationOptions; Update-CsUserDatabase; Start-Sleep 1; $i++}
    } while (-not $repeat3)
    
    ######################################################################################################
    #
    # Get-CsUser | ? {$_.Identity -match $device}
    #
    ######
    
    #Get-CsAnalogDevice
    
    #7. Add to RGS
    
    #Get-CsRgsAgentGroup -name $RGS_Agent_Group |foreach {$_.AgentsByUri} |foreach {$_.AbsoluteUri}
    
    
    # !!! #
    
    Write-Verbose "" -Verbose
    Update-CsUserDatabase
    #Start-Sleep 10
    
    Clear-Variable x
    
    #Write-Verbose "vorher01" -Verbose
    #(Get-CsRgsAgentGroup -name $RGS_Agent_Group).AgentsByUri
    
    Write-Verbose "$device is added to the AgentGroup $RGS_Agent_Group ..." -Verbose
    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Insert(0, "sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_New
    
    #Write-Verbose "00" -Verbose
    
    #Write-Verbose "middle" -Verbose
    #(Get-CsRgsAgentGroup -name $RGS_Agent_Group).AgentsByUri
    Start-Sleep 1
    Set-CsRgsAgentGroup $x -ErrorAction SilentlyContinue
    
    
    #Write-Verbose "01" -Verbose
    
    #Write-Verbose "nachher" -Verbose
    #(Get-CsRgsAgentGroup -name $RGS_Agent_Group).AgentsByUri
    #Clear-Variable x
    
    $repeat4 = $true
    $i = 0;
    
    do {
    $y = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    #Write-Verbose "1" -Verbose
    $DevAdded = $y.AgentsByUri | ? {$_.LocalPath -eq ""+$device+$SIP_Domain}
    #Write-Verbose "2" -Verbose
    if (-not ($DevAdded -eq $null)) {
    #Write-Verbose "3" -Verbose
     $repeat4 = $false
     Write-Verbose "$device was added to AgentGroup $RGS_Agent_Group successfully..." -Verbose
    
    } else {
    #Write-Verbose "4" -Verbose
    Write-Verbose "Waiting for device to be ready... $i" -Verbose
    #Write-Verbose "5" -Verbose
    Start-Sleep $i
    $i=$i+20
    Clear-Variable x
    #Write-Verbose "6" -Verbose
    
    Write-Verbose "Adding $device to AgentGroup $RGS_Agent_Group ..." -Verbose
    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Insert(0, "sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_New
    Start-Sleep 1
    
    Set-CsRgsAgentGroup $x -ErrorAction SilentlyContinue
    #Write-Verbose "7" -Verbose
    }
    
    Clear-Variable y
    
    } while ($repeat4)
    
    
    
    #Get-CsRgsAgentGroup -name $RGS_Agent_Group |foreach {$_.AgentsByUri} |foreach {$_.AbsoluteUri}
    
    #8. In Attribute Editor, restore "msRTCSIP-ApplicationOptions"=8
    Write-Verbose "$device is changed back to an analog device..." -Verbose
    Set-ADUser $device -Add @{"msRTCSIP-ApplicationOptions"=8}
    
    $i=1
    $repeat6 = $true
    do {
    if (((Get-ADUser $device -properties msRTCSIP-ApplicationOptions)."msRTCSIP-ApplicationOptions") -eq 8) {
      Write-Verbose "AD-User changed successfully..." -Verbose
      $repeat6 = $false
      }
    } while ($repeat6)
    
    do {
      $repeat5 = $true
    
      if (-not ((Get-CsAnalogDevice) -eq $null)){
        $DevIsSet = Get-CsAnalogDevice |where {$_.Name.Contains("$device")}
      } else {
      $DevIsSet = $false
      }
    
      if ((-not $DevIsSet) -or ($DevIsSet -eq $null)) {
        Write-Verbose ('AnalogDevice '+$device+' is still an "Agent..." '+$i) -Verbose
        Start-Sleep 1
        $i++
    
        $repeat5 = $true
            
      } else {$repeat5 = $false; Write-Verbose ('AnalogDevice '+$device+' is an analog device again."') -Verbose}
    } while ($repeat5)
    
    Write-Output "|$device| was added to the group |$RGS_Agent_Group| and the group was configured to |$RoutingMethod_new| !"
    Write-Verbose "The changes will be live shortly..." -Verbose
    
    Stop-Transcript

    To remove the device again you can use this script:

    $scriptname = $myinvocation.mycommand.name
    if (!(Test-Path C:\install)) {New-Item C:\install -type directory}
    if (!(Test-Path C:\install\scripts)) {New-Item C:\install\scripts -type directory}
    if (!(Test-Path C:\install\scripts\logs)) {New-Item C:\install\scripts\logs -type directory}
    if (!(Test-Path C:\install\scripts\logs\$scriptname)) {New-Item C:\install\scripts\logs\$scriptname -type directory}
    
    $date = Get-Date
    Start-Transcript ("C:\install\Scripts\logs\$scriptname\\"+$date.Day+"_"+$date.Month+"_"+$date.Year+"___"+$date.Hour+"_"+$date.Minute+".log")
    
    Import-Module ActiveDirectory
    Import-Module Lync
    
    ########################################################
    # vars EDIT HERE
    ########################################################
    $number = "913" #number of analog phone
    $device = "t"+$number #name for User in AD + Lync
    $displayName = "Analog 913 (mobile)"  #name of the device
    $password = ConvertTo-SecureString -String "Passw0rd!" -AsPlainText -Force #Passwort for created User
    $RegistrarPool = "lync.company.local" #Lync RegistrarPool
    $Gateway = "dv-vgae1.company.local" #Gateway for the device, could also be the PSTN-Gateway
    $UPN_End = "@company.com" #User-Domain for UPN-Creation; also possible @subdomain.company.com
    $SIP_Domain = "@company.de" #SIP-Domain
    $RGS_Agent_Group = "test" #Agent-Group-Name
    $RoutingMethod_old = "Parallel"  #standard Routing Method
    $RoutingMethod_new = "Attendant" #needed Routing Method
    
    ########################################################
    # DO NOT EDIT after here.
    ########################################################
    
    
    #0. Remove all!
    Remove-ADUser $device -Confirm:$false
    
    Update-CsUserDatabase
    
    $x = Get-CsRgsAgentGroup -name $RGS_Agent_Group
    $x.AgentsByUri.Remove("sip:"+$device+$SIP_Domain)
    $x.RoutingMethod = $RoutingMethod_old
    Set-CsRgsAgentGroup $x
    
    Update-CsUserDatabase
    
    Start-Sleep 180
    Write-Output "|$device| removed from |$RGS_Agent_Group| and the group was changed again to |$RoutingMethod_old| !"
    
    
    Stop-Transcript

    • Als Antwort vorgeschlagen Jamilian Mittwoch, 15. Mai 2013 07:52
    •