Powershell script for AD help


hi all,

i trying disable on 2 million unused window accounts in active directory.  have powershell command running keeps on timing out.  make simple, want use command #1 example found microsoft article.  command #2 command running keeps on timing out.  want insert command # 2, command # 1, unsure add or paste it.  hoping can me this. 

thanks in advance,

tt

command # 1: (i want use com # 1, however, don't know copy , paste parts in com # 2, com # 1.  also, if need delete parts com # 1. ) 

$adobjects = get-aduser -filter {-not(useraccountcontrol -band 2)} -erroraction stop; $adobjects | foreach-object {start-sleep -milliseconds 200; $_}

command # 2: (timing out command)

get-aduser -filter 'name -like "*"' -searchbase "ou=users,dc=test,dc=abc,dc=ca,dc=com" | disable-adaccount

here article found below:

http://social.technet.microsoft.com/wiki/contents/articles/32418.active-directory-troubleshooting-server-has-returned-the-following-error-invalid-enumeration-context.aspx

 


you on working issue.  hre how enumerate enabled accounts , disable them.  subject limits configured ad site.

get-aduser -filter {enabled -eq $true} | disable-adaccount

do not use "erroraction stop"  should not errors on retrieving objects except if ad faulty. 


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file