Update your Lync Note with a Quote of the Day – API Powershell


Following on playing with the API this script is just for fun. I have created a scheduled task that runs daily and updates the quote of the day for my Lync note…. have fun!

p.s it requires internet access!

Here is the sample code


and here is my updated Lync Client




here is the code so copy and paste

#Load Assembly
$assemblyPath = “C:\Program Files (x86)\Microsoft Office 2013\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.DLL”
Import-Module $assemblyPath
$client = [Microsoft.Lync.Model.LyncClient]::GetClient()

#Get Qoute of the Day
$url = "http://feeds.feedburner.com/brainyquote/QUOTEBR"
$data = Invoke-RestMethod -Uri $url
$qotd = $data[0].description

#Publish QoTD to Note
$instanceSelf = $Client.Self
$noteInfo = New-Object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
$noteInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::PersonalNote, $qotd)
$Publishnote = $instanceSelf.BeginPublishContactInformation($noteInfo, $null, $null)

Comments (6)

  1. Lifrommortalkombat says:

    cool stuff thanks

  2. Peter says:

    Where do i put this code in? Do I save it somewhere? thanks for sharing!!

  3. helpful stranger says:

    Peter: It’s PowerShell code. Use MS PowerShell to execute it.

  4. Stranger says:

    Can I do the same with Lync 2010? If yes, please advice, the files Microsoft.Lync.Model.DLL is in a Zip file :'(

  5. dave grubber says:

    Guys, I have a proxy which needs authentication so get the following error :

    Invoke-RestMethod :
    Access Denied (authentication_failed)
    Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your
    credentials can be verified.
    This is typically caused by an incorrect username and/or password, but could also be caused by network problems.
    At line:1 char:9
    + $data = Invoke-RestMethod -Uri $url
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

    Can you tell me a way round this or whats missing so that it can prompt me to use the proxy ?



  6. sandeep Kumar Dash says:

    Am getting an error while trying it to run it on mS poweshell and tht error is:

    Import-Module : The specified module ‘C:Program Files (x86)Microsoft Office 2013LyncSDKAssembliesDesktopMicrosoft.Lync.Model.DLL’ was not loaded because no valid module file was
    found in any module directory.
    At line:3 char:14
    + Import-Module <<<< $assemblyPath
    + CategoryInfo : ResourceUnavailable: (C:Program File….Lync.Model.DLL:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

    Unable to find type [Microsoft.Lync.Model.LyncClient]: make sure that the assembly containing this type is loaded.
    At line:4 char:44
    + $client = [Microsoft.Lync.Model.LyncClient] <<<< ::GetClient()
    + CategoryInfo : InvalidOperation: (Microsoft.Lync.Model.LyncClient:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

    The term ‘Invoke-RestMethod’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify t
    hat the path is correct and try again.
    At line:8 char:26
    + $data = Invoke-RestMethod <<<< -Uri $url
    + CategoryInfo : ObjectNotFound: (Invoke-RestMethod:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Cannot index into a null array.
    At line:9 char:15
    + $qotd = $data[ <<<< 0].description
    + CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray