VeeamON 2021: Free Online Conference - Register Now VeeamON 2021: Free Online Conference - Register Now

Enable Disabled domain accounts with powershell

Home Forums Microsoft Networking and Management Services Active Directory Enable Disabled domain accounts with powershell

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    BryanRy
    Member
    #623965

    I need to enable or disable account on active directory domain controller (Server 2012) through powershell wmi:
    1. I tried using command: wmic useraccount where “name=’myusername'” set disabled=true

    It returns an error:
    Updating property(s) of ‘\\MYDCONTROLLER\ROOT\CIMV2:Win32_UserAccount.Domain=”
    Mydomain”,Name=”myusername”‘
    ERROR:
    Description = Generic failure

    2. I tried using command:
    PS C:\Windows\system32> Get-WmiObject Win32_UserAccount -filter “LocalAccount=False”|?{$_.name -eq “userName”} |%{$_.disabled=$true;$_.passwordChangeable=$true;$passwordrequired=$true;$disabled=$true;$_.put()}

    This returns error:

    Exception calling “Put” with “0” argument(s): “Generic failure “
    At line:1 char:174
    + … isabled=$false;$_.put()}
    + ~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    I found this command in
    https://www.experts-exchange.com/questions/27803796/Enable-Disabled-LOCAL-accounts-with-Powershell.html
    Any ideas? I know how to use Get-aduser or other commands, but it need to be done via wmi

    • This topic was modified 1 year, 7 months ago by AvatarBryanRy.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Free Online Conference - May 25th and 26th

VeeamON 2021: Free Online Conference

Join us to gain your professional edge with technical and visionary learning from the brightest minds in IT at the definitive conference for Modern Data Protection.

Register Now

Sponsored By