Last active
August 29, 2015 14:00
-
-
Save tjbenator/46561e01a75edc6d982a to your computer and use it in GitHub Desktop.
Enable/Disable Microsoft Lync (per user)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Enable/Disable Microsoft Lync | |
.DESCRIPTION | |
Enable/Disable Microsoft Lync's "Auto Run When Logon To Windows" and "Auto Open Main Window When Startup". | |
.NOTES | |
Author : Travis Beck | |
Last Modified : 2014/05/01 | |
#> | |
param ( | |
[switch]$enable = $false, | |
[switch]$disable = $false | |
) | |
$path = "HKCU:\Software\Microsoft\Communicator" | |
if ($enable) { | |
Write-Host "Enabling Lync on Startup" | |
$value = 1 #Enable | |
} else { | |
$value = 0 #Disable | |
Write-Host "Disabling Lync on Startup" | |
} | |
Set-ItemProperty -Path $path -Name AutoRunWhenLogonToWindows -Value $value -Type DWord | |
Set-ItemProperty -Path $path -Name AutoOpenMainWindowWhenStartup -Value $value -Type DWord | |
if ($enable) { | |
Write-Host "Starting Lync..." | |
& 'C:\Program Files (x86)\Microsoft Lync\communicator.exe' | |
} | |
if ($disable) { | |
#Kill Lync if active | |
$ProcessActive = Get-Process communicator -ErrorAction SilentlyContinue | |
if ( $ProcessActive -ne $null ) { | |
Write-Host "Stopping Communicator Process" | |
Stop-Process -processname communicator | |
} | |
#Kill Lync Splash Screen | |
$ProcessActive = Get-Process sllauncher -ErrorAction SilentlyContinue | |
if ( $ProcessActive -ne $null ) { | |
Write-Host "Stopping Lync Splash Screen (sllauncher)" | |
Stop-Process -processname sllauncher | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment