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 :
Microsoft Dynamics AX (Archived)

Powershell management shell - restrictions

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

I'm writing a script to enable a group of users and to give them Sysadmin, which can be run after an environment restore.

So the problem i'm having, is that powershell/management shell points to one AOS only. This is fine when you have 1 AOS on the server, but if you have 2 or more you can't choose which one the command runs for. This isn't a problem for most commands e.g. 'Import-AXModelStore' because you can pass parameters to choose which database to use.

My problem lies in using the command 'Add-AXSecurityRoleMember'. There are no parameters to choose a specific dynamics instance, therefore it runs on whatever AOS the management shell is pointing towards. (for me this is 'AOS60$02')

Is there any way to point the management shell to a specific AOS, so that you can choose where these commands are being run?

Things I have tried:

  • .NET Business Connector (extremely undocumented for powershell)
    • got close to achieving this, but lacked documentation (and X++ documentation doesn't quite translate to powershell perfectly)
  • Using SQL commands
    • Not sure how good practise it is to directly update the AX database
  • Using powershell to call a static class method
    • This I got working, but am looking for a way to accomplish this without x++ or any customizations to the systems. 

I'm currently using SQL commands (in powershell) to update the 'USERINFO' table and set 'ENABLE' to 1.

I also know that you can enter a new record in 'SECURITYUSERROLE' to give a user sysadmin, but it doesn't seem like a good option to be directly updating/changing tables in the database?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    I've changed the version from to Microsoft Dynamics AX (current version) to AX 2012, because I'm pretty sure that the question is about AX 2012 and not AX 7.

    I've also separated tags with comma and removed the Dynamics AX tag, because this whole forum is about Dynamics AX.

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

    What if you simply change the default configuration on that machine? Try it manually first and if it works, you can automate it. That would allow you not having to reinvent what Add-AXSecurityRoleMember does.

    If you decide to use Business Connector anyway, you may want to look at my example for AX 2009. There is no documentation for "Business Connector for Powershell", because no such thing exists. But there is documentation for Business Connector and documentation for Powershell (including how to use .NET assemblies there).

  • Community Member Profile Picture
    on at

    Cheers Martin,

    Can't believe that completely crossed my mind...

    Whichever AOS is selected as default in the configuration manager, is the AOS that the management shell will point towards.

    Next task will be to figure out how to automate setting the default configuration.

    I did also get some problems when using the business connector but ill stick them in another thread as you have answered this question already.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    I you mean the client configuration, Set-AXConfig cmdlet in DynamicsAxCommunity module should be able to handle it. If it's about the server configuration, the module can still give you some hints.

  • Community Member Profile Picture
    on at

    Perfect, I actually only needed the line:

    "Set-ItemProperty -Path $ConfigPath -Name Current -Value $ConfigName"

    With ConfigPath being the path to the registry key, and ConfigName being the name of the configuration.

    Cheers Martin

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans