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
  • Avatar

    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=”
    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
    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, 3 months ago by AvatarBryanRy.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.