I was a little bored this morning so i wrote this script as i am trying to learn powershell

it 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)

 

 

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

Advertisements