This script will send an Instant Message to Lync Client Contact for User.
This script is to help users to send Instant Message via PowerShell when they are inconvenient with Lync Client UI.
This script contains one advanced function Send-OSCLyncInstantMessage, you can use this script in the following ways:
Step1: Prerequisite before running this script.
Step2: Start Lync Client 2010 and Log in
Step3: Run the script in the Lync Server Management Shell, type the one command: Import-Module <Script Path> at the prompt.
For example, type Import-Module C:\Script\SendLyncInstantMessage.psm1
Here are some code snippets for your references.
#Start Conversation $msg = New-Object "System.Collections.Generic.Dictionary[Microsoft.Lync.Model.Conversation.InstantMessageContentType,String]" #Add the Message $msg.Add(0,$message) #choose Modality Type $Modality = $Conversation.Modalities[1] #Start the Dialog $null = $Modality.BeginSendMessage($msg, $null, $msg) #Send the Message $null = $Modality.BeginSendMessage($msg, $null, $msg)
#Start Conversation $msg = New-Object "System.Collections.Generic.Dictionary[Microsoft.Lync.Model.Conversation.InstantMessageContentType,String]" #Add the Message $msg.Add(0,$message) #choose Modality Type $Modality = $Conversation.Modalities[1] #Start the Dialog $null = $Modality.BeginSendMessage($msg, $null, $msg) #Send the Message $null = $Modality.BeginSendMessage($msg, $null, $msg)
Example 1: Send a Plain Text Instant Message "Test" to User1 on your Lync Client Contact List..
Command: Send-OSCLyncInstantMessage -Alias User1 -Message "Test"
Screenshot:
![]()
Example 2: Send a Plain Text Instant Message "Test" to User1 and User2 on your Lync Client Contact List..
Command: Send-OSCLyncInstantMessage -Alias User1,User2 -Message "Test"
Screenshot:
![]()
Lync Client 2010
PowerShell 2.0