Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

option to run script again

$
0
0

Hi there,

 

I have a powershell script that gives me the option to either start or stop some services.

The script is below:-

cls

"Script to Start and Stop Sophos Web Components"

""

"Press 1 to STOP Sophos Web"

"Press 2 to START Sophos Web"

""

$a = Read-Host "Please enter your selection"

switch ($a)

 

{

1{

Stop-Service swi_service

Stop-Service savservice

Stop-Service "sophos web control service"

Stop-Service "Sophos Anti-Virus"

Get-Service | where name -like "*swi*"

Get-Service | where name -like "*sop*"

Get-Service | where name -like "*sav*"

}

2{

Start-Service swi_service

Start-Service savservice

Start-Service "sophos web control service"

Start-Service "Sophos Anti-Virus"

Get-Service | where name -like "*swi*"

Get-Service | where name -like "*sop*"

Get-Service | where name -like "*sav*"

}

}

 

What usually happens is i stop the services do the task and the need to restart the services again afterwards.

 

Can anybody help with getting the script, once i have selected either 1 or 2 and the script has run to give me the option to either go back to the start and give me the 2 options again or exit the script?

 

Many thanks,

 

Pete


Viewing all articles
Browse latest Browse all 6937

Trending Articles