Enable Disabled domain accounts with powershell
- This topic has 1 reply, 2 voices, and was last updated 1 year, 3 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Home › Forums › Microsoft Networking and Management Services › Active Directory › Enable Disabled domain accounts with powershell
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
You must be logged in to reply to this topic.
Find out more about our cookie policy here.