need some help writing a Powershell script or a way to create a scheduled task to restart two services if either of them isn't running. The script needs to include logic to stop a process if the service doesn't stop within 10 minutes and needs to use sleep timers to wait for services to stop and then idle after both are stopped. See details below:
Any help would be greatly appreciated especially since I'm a newbie with using Powershell.
Dynamics AX Object Server
5.0$01-DynamicsAX-Prod-PB-01
Dynamics AX Object Server
5.0$02-DynamicsAX-Prod-PB-02
1. If ANY of the services are
not running, execute the following procedure to restart ALL of the
services.
Stop all the AOS services using NT service account “******” on servers.
Dynamics AX Object Server
AX Object Server 5.0$01-DynamicsAX-Prod-PB-01
Dynamics AX Object Server
5.0$02-DynamicsAX-Prod-PB-02
Note: These services can sometimes take several minutes to stop.
If the service does not stop after 10 minutes, use Task Manager to
terminate the “Ax32Serv.exe” processes.
Leave all
AOS services in a stopped status for 5 minutes.
Start all the AOS services
using NT service account “******” in servers
Dynamics
AX Object Server 5.0$01-DynamicsAX-Prod-PB-01
Dynamics AX Object Server
5.0$02-DynamicsAX-Prod-PB-02