I am writing a powershell script to make a call to the system after a database backup and restore. We have a process that requires the databases to be synced between testing and production. After a restore Epicor needs some tasks to be completed before it is ready to test, reset some compnay configurations and such. So I thought this is perfect for a script that can run do the backups and restores and then make the changes. But the ICE sysagentsvc is giving me some issues. I submit to the update and get a 200 response but the values are not persisted.
Interesting enough if I try through the swagger UI I get the same issue, a good response but the agent url does not change.
I did try stopping the agent service and then restarting however no change.
get-service -name EpicorICETaskAgent3.1.600.0 | Stop-Service
{Code Below}
get-service -name EpicorICETaskAgent3.1.600.0 | Start-Service
Check it out:
$envios = @(‘Development’,‘Test’,‘Pilot’)
$user = ‘’
$password= ‘’
$pwd = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object Management.Automation.PSCredential ($user, $pwd)
$getJson = @{ whereClauseSysAgent = ‘’; whereClauseSysAgentSched = ‘’; whereClauseSysAgentTask = ‘’; whereClauseSysAgentTaskParam=’’; pageSize = 0; absolutePage = 0;}
foreach($e in $envios)
{
$params = @{
Uri = 'https://{Epicor BASE URL}/' + $e + '/api/v1/Ice.BO.SysAgentSvc/GetRows'
Method = 'Post'
ContentType = 'application/json'
Cred = $cred
Body = $getJson | ConvertTo-Json
}
$r = Invoke-RestMethod @params
foreach($t in $r.returnObj.SysAgent)
{
$t.SysAppserverURL = "net.tcp://{Epicor BASE URL}/" + $e
$t.ClientProgRootDir = "C:\inetpub\wwwroot\" + $e + "\Server"
}
Write-Host $r.returnObj.SysAgent.SysAppserverURL
$body = @{
ds = @{
SysAgent = $r.returnObj.SysAgent
SysAgentSched = $r.returnObj.SysAgentSched
SysAgentTask = $r.returnObj.SysAgentTask
SysAgentTaskParam = $r.returnObj.SysAgentTaskParam
}
};
$body | ConvertTo-Json -Depth 100 | Out-file "c:/inner.json"
$paramsUpdate = @{
Uri = 'https://{Epicor BASE URL}/' + $e + '/api/v1/Ice.BO.SysAgentSvc/Update'
Method = 'Post'
ContentType = 'application/json'
Cred = $cred
Body = $body | ConvertTo-Json -Depth 100
}
$r = Invoke-RestMethod @paramsUpdate
$r = Invoke-RestMethod @params
Write-Host $r.returnObj.SysAgent.SysAppserverURL
Write-Host ""
}