How to check if the Lync is in presentation mode?

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!

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[&#039;ApplicationSharing&#039;].ParticipationState -eq &#039;Sharing&#039; }).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 &#039;Check if Lync is in running in presentation mode...&#039; -Source ${CmdletName}
	If ((Get-Process -Name lync -ErrorAction SilentlyContinue).Count -gt 0)
	{
		$LyncResult = Execute-ProcessAsUser -Path &quot;$PSHOME\powershell.exe&quot; -Parameters &quot;-Command &amp; { &amp; &#039;$dirSupportFiles\Test-LyncPresentation.ps1&#039;; Exit `$LastExitCode }&quot; -RunLevel LeastPrivilege -Wait -PassThru
	}
	Else
	{
		$LyncResult = 3
	}
	switch ($LyncResult)
	{
		&#039;1&#039; {
			Write-Log -Message &quot;Detected that Lync is in Presentation mode.&quot; -Source ${CmdletName}
			[nullable[boolean]]$IsLyncPresenting = $true
		}
		&#039;2&#039; {
			Write-Log -Message &quot;Detected that Lync is not in Presentation mode.&quot; -Source ${CmdletName}
			[nullable[boolean]]$IsLyncPresenting = $false
		}
		&#039;3&#039; {
			Write-Log -Message &#039;Lync application is not running.&#039; -Source ${CmdletName}
			[nullable[boolean]]$IsLyncPresenting = $false
		}
		default
		{
			Write-Log -Message &quot;Failed check to see if Lync is running in Presentation mode.&quot; -Severity 3 -Source ${CmdletName}
			[nullable[boolean]]$IsLyncPresenting = $null
		}
	}
}
End
{
	Write-Output -InputObject $IsLyncPresenting
	Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
}

}

Hi DennishVH, can you please get in contact with me via Twitter or LinkedIn? Thanks, Sean.