Friday, August 16, 2013

Script to Automate the Connection to Lync Online

So you just saw that new Microsoft Download for Windows PowerShell Module for Lync Online... got you pretty excited right?!

At least until you finished the install and didn't read the documentation :-) were left wondering how to use it. Well don't fret any longer here is a handy script I've been using to connect. If you are running on a Windows 7 or other workstation you'll need to set your PowerShell Execution Policy.

# Script to Automate connection to Lync Online
# Created By Jonathan McKinney (blog.lyncdialog.com)
# Time2Market 2013


Import-Module LyncOnlineConnector

$cred = Get-Credential
$CsSession = New-CsOnlineSession -Credential $cred

Import-PSSession $CsSession

Write-Host  `r`n 'To get a list of available Lync Online commands Enter Get-Command -Module <ScriptNameAbove>' `r`n -ForegroundColor Yellow
Write-Host  `r`n 'To remove Remote Powershell Session Enter Get-PsSession and then Remove-PsSession -Id <ID number of session listed>' `r`n -ForegroundColor Yellow


Pretty neat, huh?

So what can you do once you have access? Mostly look around and wish you could change stuff.

Couple of useful things you can do... Set ACP info and Grant policies to users.

Here is how you set ACP info do it if your customer uses Intercall

Set-CsUserAcp -Identity "lynctest at domain.com" -Name "InterCall" -Domain "mslync.audiocontrols.net" -TollNumber "4255551234" -TollFreeNumbers "8665551234" -ParticipantPasscode "4255552345" -Url http://www.intercall.com/l/dial-in-number-lookup.php

Here is an example of how you can Grant no recording through a conferencing policy

Grant-CsConferencingPolicy "lynctest at domain.com" -PolicyName BposSAllModalityNoRec 

So... Ummm... how do you get a list of all the Policies available (since we can't change or add them)

Get-CsConferencingPolicy

Wow... big list eh?

or if you just want to see the names of the policies

Get-CsConferencingPolicy | select identity

Here is a list of commands that I have access to...

CommandType     Name
-----------     ----
Function        Copy-CsVoicePolicy
Function        Disable-CsMeetingRoom
Function        Enable-CsMeetingRoom
Function        Get-CsAudioConferencingProvider
Function        Get-CsClientPolicy
Function        Get-CsConferencingPolicy
Function        Get-CsDialPlan
Function        Get-CsExternalAccessPolicy
Function        Get-CsExUmContact
Function        Get-CsHostedVoicemailPolicy
Function        Get-CsImFilterConfiguration
Function        Get-CsMeetingConfiguration
Function        Get-CsMeetingRoom
Function        Get-CsOnlineUser
Function        Get-CsPresencePolicy
Function        Get-CsPrivacyConfiguration
Function        Get-CsPushNotificationConfiguration
Function        Get-CsTenant
Function        Get-CsTenantFederationConfiguration
Function        Get-CsTenantHybridConfiguration
Function        Get-CsTenantLicensingConfiguration
Function        Get-CsTenantPublicProvider
Function        Get-CsUserAcp
Function        Get-CsVoicePolicy
Function        Grant-CsClientPolicy
Function        Grant-CsConferencingPolicy
Function        Grant-CsDialPlan
Function        Grant-CsExternalAccessPolicy
Function        Grant-CsHostedVoicemailPolicy
Function        Grant-CsVoicePolicy
Function        New-CsEdgeAllowAllKnownDomains
Function        New-CsEdgeAllowList
Function        New-CsEdgeDomainPattern
Function        New-CsExUmContact
Function        Remove-CsExUmContact
Function        Remove-CsUserAcp
Function        Remove-CsVoicePolicy
Function        Set-CsExUmContact
Function        Set-CsMeetingConfiguration
Function        Set-CsMeetingRoom
Function        Set-CsPrivacyConfiguration
Function        Set-CsPushNotificationConfiguration
Function        Set-CsTenantFederationConfiguration
Function        Set-CsTenantHybridConfiguration
Function        Set-CsTenantPublicProvider
Function        Set-CsUser
Function        Set-CsUserAcp


Welcome to Lync Online PowerShell...

3 comments:

  1. Great post Jonathan. I used the Set-CSUserACP command already to set the initial ACP info for my users.

    But now in one of our countries the tollnumber has been changed.
    Is there a way with Set-CSUserACP to only change the TollNumber, without providing the ParticipantPasscode which is already filled in ?

    ReplyDelete
  2. Already found a solution which works for me, but I hope you may have a simpler solution:

    $ACP = (get-csuseracp -Identity ).ACPinfo

    $ACPtollNumber = $ACP.Split(">")[2].Split("<")[0]
    $ACPparticipantPassCode = $ACP.Split(">")[4].Split("<")[0]
    $ACPdomain = $ACP.Split(">")[6].Split("<")[0]
    $ACPname = $ACP.Split(">")[8].Split("<")[0]
    $ACPurl = $ACP.Split(">")[10].Split("<")[0]

    $NewTollNumber = "1234567890"

    Set-CSUserACP -domain $ACPdomain -name $ACPname -ParticipantPassCode $ACPparticipantPassCode -TollNumber $NEWtollNumber

    ReplyDelete
    Replies
    1. your solution is not better than anything I would come up with. Unfortunately Set-CSUserACP needs all the fields populated even if they aren't changing.

      Delete