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

  • Dynamics AX 2012 Profile Picture
    40 on at
    RE: I want ax job activities through powershell

    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()

     

  • Verified answer
    Martin Dráb Profile Picture
    231,923 Most Valuable Professional on at
    RE: I want ax job activities through powershell

    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
    RE: I want ax job activities through powershell

    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
    231,923 Most Valuable Professional on at
    RE: I want ax job activities through powershell

    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.

  • Suggested answer
    nunomaia Profile Picture
    11 Moderator on at
    RE: Microsoft Dynamics AX 2012 - I want ax job activities through powershell

    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  

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,233 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans