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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to Enable AX User through Powershell

(0) ShareShare
ReportReport
Posted on by 310

Can some one please let me know the command how to Enable an AX User who is already disabled with in AX2012 R3 through Powershell.

i tried through AX Management shell below command 

Enable-AXUser –AXUserId Demo –Server DemoAX

but it says

Enable-AXUser : The term 'Enable-AXUser' is not recognized as the name of a cmdlet, function, script file, or operable program.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Alex Kwitny Profile Picture
    395 on at
    RE: How to Enable AX User through Powershell

    I needed to disable/enable users via PS and hoped somebody already solved this. Guess not, here's the solution:

    $AXUserId = "TestUser"
    $EnableUser = $false # Or $true if you want to enable the user
    
    Add-Type -Path “C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\Microsoft.Dynamics.BusinessConnectorNet.dll”
    
    $ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta
    
    $ax.logon($null, $null, $null, $null)
    $ax.CallStaticClassMethod("SysUserManagement", "setUserEnabled", $AXUserId, $EnableUser)
    
    Write-Host "Set AX user $AXUserId enabled: $EnableUser"

  • Vasudev Kochuveettil Profile Picture
    310 on at
    RE: How to Enable AX User through Powershell

    ya Vilmos let me go that  route which you pointed out

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How to Enable AX User through Powershell

    Let me re-iterate my answer - via Business Connector you could do CRUD operations on tables, and can call any logic you want within AX, directly from PowerShell. That gives you a very easy way to enable your user accounts.

    I am using the same way in my PowerShell release script to validate if AIF ports are running on all AOS instances once the services are back online, as an example:

    https://www.daxrunbase.com/2016/08/17/validate-aif-ports-running-ax/

  • Vasudev Kochuveettil Profile Picture
    310 on at
    RE: How to Enable AX User through Powershell

    Sorry Chaitanya this doesn't serve my purpose.

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: How to Enable AX User through Powershell

    Hi,

    As we don't have a direct cmdlet to enable a user using power shell as an alternative, you can use the cmdlet Remove-AXSecurityRole and remove all the security roles for the intended user including SystemUser.

    By doing so the user can login into AX but he gets a blank screen on logging in with no access to any modules.

    Refer Link:

    (Remove-AXSecurityRole)

    technet.microsoft.com/.../jj720281.aspx

    Hope this helps you.

    Thanks,

    Chaitanya Golla

  • Vasudev Kochuveettil Profile Picture
    310 on at
    RE: How to Enable AX User through Powershell

    Hi Vilmos,

    to be clear i am not creating AX users through powershell, i have AX Users already present within AX who are disabled and i want to re-enable only them.

    in our scenario we have 300+ AX Users who use our AX System and in that about 100+ are disabled and we don't remove them from AX, Due to various reasons we tend to disable them and when needed we re-enable back them and going forward we would have 7000+ AX users

    and due to some business reasons we don't use AD and we have so many Customized AX Security roles which is assigned to AX Users, so AD is going to have lots and lots of groups for various roles which will again complex it out

    so as shown in my screenshot disable AXUser was pretty simple but Enable back a disabled AXUser seems not straight forward.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How to Enable AX User through Powershell

    You could also call AX through Business Connector via PowerShell to update the user information and get it enabled either in the table, or through the actual functionality that the AX form is using (which does additional validations in the AD).

    [View:https://blogs.msdn.microsoft.com/axinthefield/harness-the-power-of-powershell-and-the-business-connector-too/:750:50]

    My question would be why are you bothering to create/enable users from PowerShell, when AX supports using Active Directory groups, from where users could be automatically added to AX, and get specific security roles allocated?

  • Chaitanya Golla Profile Picture
    17,225 on at
    RE: How to Enable AX User through Powershell-- AX2012 R3

    Hi,

    If you look at the syntax of New-AXUser cmdlet there is an option to enable the newly created user.

    Parameter: [-Disabled]

    Syntax:

    New-AXUser -AccountType <String> -AXUserId <String> -UserDomain <String>

    -UserName <String> [-ClearTextPassword <String> ] [-Company <String> ]

    [-CreateInProvider] [-Disabled] [-PartitionKey <String> ] [ <CommonParameters>]

    Refer link: technet.microsoft.com/.../jj720263.aspx

    This cmdlet allows to create a new user in AX and by default, users are enabled. Probably you can make use of this(by adjusting your automation steps sequence).

    Thanks,

    Chaitanya Golla

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans