Setting Properties on AD Users

by Feb 20, 2009

If you'd like to find Users in your Active Directory and bulk-change certain properties, you may not need 3rd party extensions. Here is an example based solely on PS that finds all users with dialin permissions and resets the permissions:

$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]'', 
'(&(objectCategory=person)(objectClass=user)(msNPAllowDialin=FALSE))')

$searcher.PageSize = 1000
$searcher.findall() | % { $_.GetDirectoryEntry() } |
% { $_.PutEx(1, "msNPAllowDialin", 0); $_.SetInfo() }