Share via


Powershell Script to Check / Stop & Start Lync Services

this script will give you a little menu system to check, stop & start lync services….

Hopefully it will help someone… and i might improve it Smile

******************************************************************************************************

set-executionpolicy unrestricted

$foreverloop = 4

Write-host "Thank you for using this little powershell script" -Backgroundcolor Black -Foregroundcolor Green
Write-host "Please repost and feel free to use!" -Backgroundcolor Black -Foregroundcolor Green
write-host "Always nice to hear feedback… Twitter @mccabej or email johm@microsoft.com" -Backgroundcolor Black -Foregroundcolor Green

do

{
Write-host "Please Select 1 if you want to check the status of all Lync Services"
Write-host "Please Select 2 if you want to stop all services"
write-host "Please Select 3 if you want to start all services"
write-host "Press 0 to exit"
$menu = Read-host ("Enter your Selection and Press Enter")
$foreverloop = $menu

cls

if ($menu -eq 1)
{

$service = get-service RTC*
$service
Read-Host "Press Enter Key To Return To The Menu"
cls
}
Elseif ($menu -eq 2)
{
Foreach ($s in $service)
{
write-host
write-host
$s

{
if ($s.Status -eq "Running") {Stop-Service $s.Name -Force}

}

Read-host "Press Enter Key To Return To The Menu"
cls
}
Elseif ($menu -eq 3)
{
Foreach ($s in $service)
{
write-host
write-host
$s
if ($s.Status -eq "Stopped") {Start-Service $s.Name}
}
Read-host "Press Enter Key To Return To The Menu"
cls
}

Else
{Write-host "Exiting…."
}
}
Until ($foreverloop -eq 0)

***************************************************************************************************************

Comments

  • Anonymous
    January 01, 2003
    We have used different method -->Get-CsWindowsService & Start-CsWindowsService power-shell lync command and created the below script for checking lync services & start it if its not running. It will send html report in email as well.

    http://msexchange.me/2014/03/28/check-lync-services-and-start-if-not-running/

  • Anonymous
    October 07, 2011
    maybe good if multiple servers are included

  • Anonymous
    May 23, 2013
    Hi, thanks for your script but i get the following error after run it. Missing closing '}' in statement block. At C:LyncHealth.ps1:61 char:27

  • Until ($foreverloop -eq 0) <<<<    + CategoryInfo          : ParserError: (CloseBraceToken:TokenId) [], Parse   Exception    + FullyQualifiedErrorId : MissingEndCurlyBrace