How to check if the Lync is in presentation mode?

//How to check if the Lync is in presentation mode?
How to check if the Lync is in presentation mode? 2016-11-08T19:42:14+00:00

The Toolkit Forums Deployment Scripts How to check if the Lync is in presentation mode?

  • Author
    Posts
  • Rajiv
    Participant
    Post count: 1
    #1731 |

    Hello

    I am currently working on PS App Deployment Toolkit for few of my applications to be deployed. This has almost all the functions that we may possibly think of when comes to deploying the applications in interactive mode. The built in function to check for powerpoint presentation mode has been very useful. Similarly, I would like to check if the Users are presenting their screen. We certainly DO NOT want to interrupt Users with interactive windows and popups during their presentation time.

    Any help would really be appreciated. Thanks much!

  • DennisVH
    Participant
    Post count: 1

    First you need to download the Lync 2013 SDK
    https://www.microsoft.com/en-us/download/details.aspx?id=36824

    extract the lyncsdk.exe using winzip
    extract lyncsdk86.msi (we are using Office 32-bit): msiexec /a lyncsdk86.msi /qb /TARGETDIR=c:\Temp
    Copy from TARGETDIR\FILES\Program Files\Microsoft Office 2013\LyncSDK\Assemblies\Desktop the files Microsoft.Lync.Model.dll & Microsoft.Office.Uc.dll to your Toolkit’s SupportFiles directory

    Also create a Test-LyncPresentation.ps1 script in the SupportFiles directory
    <pre class=”brush: powershell; gutter: true; first-line: 1; highlight: []; html-script: false”>
    function Get-ScriptDirectory
    {
    <#
    .SYNOPSIS
    Get-ScriptDirectory returns the proper location of the script.

    .OUTPUTS
    System.String

    .NOTES
    Returns the correct path within a packaged executable.
    #>
    [OutputType([string])]
    param ()
    if ($hostinvocation -ne $null)
    {
    Split-Path $hostinvocation.MyCommand.path
    }
    else
    {
    Split-Path $script:MyInvocation.MyCommand.Path
    }
    }

    $scriptDirectory = Get-ScriptDirectory

    If ((Get-Process -Name lync -ErrorAction SilentlyContinue).Count -gt 0)
    {
    Import-Module "$scriptDirectory\Microsoft.Lync.Model.dll"
    Import-Module "$scriptDirectory\Microsoft.Office.Uc.dll"

    $client = [Microsoft.Lync.Model.LyncClient]::GetClient()
    $LyncSharing = ($client.ConversationManager.Conversations | Where-Object { $_.Modalities['ApplicationSharing'].ParticipationState -eq 'Sharing' }).Count
    If ($LyncSharing -gt 0)
    {
    #Write-Host 1
    Exit(1)
    }
    Else
    {
    #Write-Host 2
    Exit(2)
    }
    }
    Else
    {
    #Write-Host 3
    Exit (3)
    }

    In Toolkit Extensions I have the following script:
    <pre class=”brush: powershell; gutter: true; first-line: 1; highlight: []; html-script: false”>
    Function Test-LyncPresentation_EY
    {
    <#
    .SYNOPSIS
    Tests wether user is presenting in a Lync/Skype meeting.
    .DESCRIPTION
    Tests wether user is presenting in a Lync/Skype meeting.
    .EXAMPLE
    Test-LyncPresentation
    .NOTES
    This needs to run as user in order to detect if a Lync/Skype meeting is in progress
    #>
    [CmdletBinding()]
    Param (
    )

    Begin
    {
    ## Get the name of this function and write header
    [string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
    Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
    }
    Process
    {
    Write-Log -Message 'Check if Lync is in running in presentation mode…' -Source ${CmdletName}
    If ((Get-Process -Name lync -ErrorAction SilentlyContinue).Count -gt 0)
    {
    $LyncResult = Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & '$dirSupportFiles\Test-LyncPresentation.ps1'; Exit `$LastExitCode }" -RunLevel LeastPrivilege -Wait -PassThru
    }
    Else
    {
    $LyncResult = 3
    }
    switch ($LyncResult)
    {
    '1' {
    Write-Log -Message "Detected that Lync is in Presentation mode." -Source ${CmdletName}
    [nullable[boolean]]$IsLyncPresenting = $true
    }
    '2' {
    Write-Log -Message "Detected that Lync is not in Presentation mode." -Source ${CmdletName}
    [nullable[boolean]]$IsLyncPresenting = $false
    }
    '3' {
    Write-Log -Message 'Lync application is not running.' -Source ${CmdletName}
    [nullable[boolean]]$IsLyncPresenting = $false
    }
    default
    {
    Write-Log -Message "Failed check to see if Lync is running in Presentation mode." -Severity 3 -Source ${CmdletName}
    [nullable[boolean]]$IsLyncPresenting = $null
    }
    }
    }
    End
    {
    Write-Output -InputObject $IsLyncPresenting
    Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
    }
    }

You must be logged in to reply to this topic.