web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

I want ax job activities through powershell

(1) ShareShare
ReportReport
Posted on by 40

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 have the same question (0)
  • Suggested answer
    nunomaia Profile Picture
    25 Moderator on at

    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  

  • Verified answer
    Martin Dráb Profile Picture
    237,874 Most Valuable Professional on at

    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.

  • Dynamics AX 2012 Profile Picture
    40 on at

    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

  • Verified answer
    Martin Dráb Profile Picture
    237,874 Most Valuable Professional on at

    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.

  • Dynamics AX 2012 Profile Picture
    40 on at

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans