E
eXPlosion_
Guest
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 needs to be done via wmi.
Continue reading...
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 needs to be done via wmi.
Continue reading...