MYOB Issues (API services stop)
Posted at August 21, 2023 01:08 pm. Last updated at February 10, 2025 11:02 am
When MYOB API Service stops all the time. We crated a script to fix this one which automatically start the MYOBApiService after 5 times then after that the temporary service will run "Temporary MYOB API AccountRight". Also this was added on Task Scheduler "MYOB API Service Check" The script of this job below.
$serviceName = 'MYOBApiService'
$serviceStatus = Get-Service -Name $ServiceName
$tempserviceName = 'Temporary MYOB API AccountRight'
$tempserviceStatus = Get-Service -Name $tempserviceName
$filename = 'C:/Users/it_3/Documents/Logs/'+(Get-Date).ToString("yyyyMMdd") +'.log'
$strEvent = ''
$ctrEvent = ''
[regex]$regex = (Get-Date).ToString("yyyyMMdd")
if ($serviceStatus.Status -eq 'Running')
{
exit;
}
if ($tempserviceStatus.Status -eq 'Running')
{
exit;
}
if ($serviceStatus.Status -eq 'Stopped')
{
Write-Host 'Service is not Running'
if(Test-Path $filename ){
$serviceName + ' is not running at ' + (Get-Date).ToString("yyyyMMdd HH:mm") >> $filename
$strEvent = Get-Content $filename
$ctrEvent = $regex.matches($strEvent).count
if ($ctrEvent -ge 5)
{
Start-Service $tempserviceName -PassThru | Format-List >> $filename
}
else
{
Start-Service $serviceName -PassThru | Format-List >> $filename
}
}
else
{
New-Item -ItemType File -Force -Path $filename
$serviceName + ' is not running at ' + (Get-Date).ToString("yyyyMMdd HH:mm") >> $filename
Start-Service $serviceName -PassThru | Format-List >> $filename
}
}
***********************************
Please check also the Imagepath of the Temporary Services the current version of MYOB.

Comments