Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

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

  • 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, 11 months ago by BryanRy.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: