On a Windows system, in the Service console, there is a recovery tab to configure actions for a service in case of failure.
How can I configure this with PowerShell?
There is currently no native PowerShell cmdlet to manage the service recovery.
However, to auto-restart a service when it fails you can use
(In a PowerShell prompt you must precede it with & and use the full name
& sc.exe failure msftpsvc reset= 30 actions= restart/5000
The official documentation is on Microsoft Docs under Sc Failure