Stopping BlackBerry Services:
#--------------------------------------------------------------------------------------------------#
Set-Variable -name selectedServices -option Constant -value @("BlackBerry Controller","BlackBerry Dispatcher","BlackBerry Router")
#--------------------------------------------------------------------------------------------------#
foreach($selectedService in $selectedServices) {
if((Get-Service -Name $selectedService).Status -ne "Stopped") {
Write-Output "Stopping $selectedService..."
Stop-Service -Name $selectedService
if((Get-Service -Name $selectedService).Status -ne "Stopped") {
Write-Output "$selectedService failed to stop. Exiting..."
exit
} else {
Write-Output "$selectedService successfully stopped."
}
} else {
Write-Output "$selectedService already stopped!"
}
}
foreach($blackberryService in (Get-Service -Name Blackberry*)) {
if($selectedServices -notcontains $blackberryService.Name) {
if($blackberryService.Status -ne "Stopped") {
Write-Output ("Stopping " + $blackberryService.Name + "...")
Stop-Service -Name $blackberryService.Name
if((Get-Service -Name $blackberryService.Name).Status -ne "Stopped") {
Write-Output ($blackberryService.Name + " failed to stop. Exiting...")
exit
} else {
Write-Output ($blackberryService.Name + " successfully stopped.")
}
} else {
Write-Output ($blackberryService.Name + " already stopped!")
}
}
}Starting BlackBerry Services: #--------------------------------------------------------------------------------------------------#
Set-Variable -name selectedServices -option Constant -value @("BlackBerry Router","BlackBerry Dispatcher","BlackBerry Controller")
#--------------------------------------------------------------------------------------------------#
foreach($selectedService in $selectedServices) {
if((Get-Service -Name $selectedService).Status -ne "Running") {
Write-Output "Starting $selectedService..."
Start-Service -Name $selectedService
if((Get-Service -Name $selectedService).Status -ne "Running") {
Write-Output "$selectedService failed to start. Exiting..."
exit
} else {
Write-Output "$selectedService successfully started."
}
} else {
Write-Output "$selectedService already running!"
}
}
foreach($blackberryService in (Get-Service -Name Blackberry*)) {
if($selectedServices -notcontains $blackberryService.Name) {
if($blackberryService.Status -ne "Running") {
Write-Output ("Starting " + $blackberryService.Name + "...")
Start-Service -Name $blackberryService.Name
if((Get-Service -Name $blackberryService.Name).Status -ne "Running") {
Write-Output ($blackberryService.Name + " failed to start. Exiting...")
exit
} else {
Write-Output ($blackberryService.Name + " successfully started.")
}
} else {
Write-Output ($blackberryService.Name + " already running!")
}
}
}
No comments:
Post a Comment