Setting Properties on AD Users

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() }

Posted Feb 20 2009, 08:00 AM by ps1

Comments

Niklas Goude wrote re: Setting Properties on AD Users
on 02-20-2009 3:41 PM

Nice Post, and nice pipe:ing! I've described a similar search function on my Blog.

www.powershell.nu

Note.

changing the PageSize property let's you search through more users/groups/computers then the default value (1000).

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.