HI,
I wanted to automate few tasks through powershell scripting like running AX jobs, view code/Batch history, completion status of ax job.
Regards,
Shivashankar
HI,
I wanted to automate few tasks through powershell scripting like running AX jobs, view code/Batch history, completion status of ax job.
Regards,
Shivashankar
I found it how to achieve this through powershell
$JobName = "xyz"
[reflection.Assembly]::Loadfile("C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Microsoft.Dynamics.BusinessConnectorNet.dll")
$ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta
# connect to ax
$ax.Logon("","","","")
if(echo $? -eq "True"){
Write-Host "logged in successfully"
$ax.CallJob("$JobName")
if(echo $? -eq "True"){
Write-Host "$JobName run successfully"
}
else{
Write-Host "$JobName NOT run"
Write-Host Logging off $ax.Logoff()
exit 1
}
}
else
{
Write-Host "Not logged in"
Write-Host Logging off $ax.Logoff()
exit 1
}
Write-Host Logging off $ax.Logoff()
It would have helped if you explained what exactly you need to elaborate. If you're not familiar with customer services, look at Using Custom Services, for example. You can find more examples in various blog posts.
If you're not familiar with SysOperation framework, consult AX2012: SysOperation introduction.
If you don't know how to put these things together, it's pretty simple. Instead of writing a special class for a custom service, you can use an existing SysOperation class and expose it as a custom service.
Hi Martin,
Thanks for your response/suggestion.
Can you elaborate more on below statement
"Also note that operations from SysOperation framework can easily be exposed as custom web services."
-Shiva
You can call web services from Powershell (using New-WebServiceProxy, most likely), or use Business Connector. You could also query database from Powershell, but opening a direct access to production databases wouldn't be a good idea.
If I was you, I would check if there aren't suitable custom services and develop my own if not.
Also note that operations from SysOperation framework can easily be exposed as custom web services.
I do not see any way of automate that using powershell. You can query SQL Tables to only read data ( for example Batch table), but I would recommend manage directly in Dynamics
André Arnaud de Cal...
293,233
Super User 2025 Season 1
Martin Dráb
231,923
Most Valuable Professional
nmaenpaa
101,156
Moderator