Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function MassIM
- {
- Try
- {
- $AssemblyPath = “C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Model.DLL”
- Import-Module $AssemblyPath
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not load required DLL files" | OutputToError
- FatalError
- }
- Try
- {
- $LyncClient = [Microsoft.Lync.Model.LyncClient]::GetClient()
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not connect to Lync client." | OutputToError
- FatalError
- }
- Try
- {
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $False
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not load Excel." | OutputToError
- FatalError
- }
- Try
- {
- $IMBook = $Excel.Workbooks.Open("C:\Users\cbrady-sa\Desktop\MassIM\List\IMList.xls")
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not open required workbook." | OutputToError
- FatalError
- }
- Try
- {
- $IMSheet = $IMBook.Worksheets.Item(1)
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not open required worksheet." | OutputToError
- FatalError
- }
- $FoundEmptyCell = $False
- $Row = 1
- While (!$FoundEmptyCell)
- {
- If ($IMSheet.Cells.Item($Row, 1).Value() -EQ $null)
- {
- $FoundEmptyCell = $True
- }
- Else
- {
- Try
- {
- $User = $IMSheet.Cells.Item($Row, 1).Value()
- $UserDesk = $IMSheet.Cells.Item($Row, 2).Value()
- $UserExt = $IMSheet.Cells.Item($Row, 3).Value()
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not load data from worksheet." | OutputToError
- FatalError
- }
- Try
- {
- $User = $User -split ','
- $UserName = $User[1] + "." + $User[0] + "@xxx.com"
- $UserName.Trim()
- $Convo = $LyncClient.ConversationManager.AddConversation()
- $MSG = New-Object "System.Collections.Generic.Dictionary[Microsoft.Lync.Model.Conversation.InstantMessageContentType,String]"
- $Mod = $Convo.Modalities[1]
- $Convo.AddParticipant($UserName)
- $MSG.Add(0, "Hello ${UserName}. Is your desk still ${UserDesk}? Is your extension still ${UserExt}?")
- $null = $Mod.BeginSendMessage($MSG, $null, $MSG)
- }
- Catch [System.Exception]
- {
- $TS = TimeStamp
- "Could not instant message${UserName}." | OutputToError
- $Error | OutputToError
- }
- $Row++
- }
- }
- $Excel.Quit()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement