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?