Notifications
Announcements
No record found.
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 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
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.
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
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.
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()
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 646 Most Valuable Professional
André Arnaud de Cal... 529 Super User 2025 Season 2
Sohaib Cheema 285 User Group Leader