Discover users that have Notes set

A field like the Notes field can be a dumping ground for all sorts of stuff.  If you want to discover what Notes have been set then try this

"`nMicrosoft"
Get-ADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(info=*))" -Properties *|
Format-Table Name, DistinguishedName, info -AutoSize -Wrap            

"`nAD provider"
Get-ChildItem -Filter "(&(objectclass=user)(objectcategory=user)(info=*))" `  -Path Ad:\"DC=Manticore,DC=org" -Recurse |
foreach {
 $user = [adsi]"LDAP://$($_.DistinguishedName)"
 $user | select @{N="Name"; E={$_.name}},
 @{N="DistinguishedName"; E={$_.distinguishedname}},
 @{N="Note"; E={$_.info}}
} | Format-Table -AutoSize -Wrap            

"`nQuest"
Get-QADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(info=*))" -IncludeAllProperties |
Format-Table Name, DN, info -AutoSize -Wrap            

"`nScript"
$root = [ADSI]""
$search = [adsisearcher]$root
$search.Filter = "(&(objectclass=user)(objectcategory=user)(info=*))"
$search.SizeLimit = 3000
$search.FindAll() | foreach {            

$user = $_.GetDirectoryEntry()
$user | select @{N="Name"; E={$_.name}},
 @{N="DistinguishedName"; E={$_.distinguishedname}},
 @{N="Note"; E={$_.info}}
} | Format-Table -AutoSize -Wrap

Use a LDAP filter to test for the presence of a Notes field and then display the Name, distinguishedname and Note.  The provider and script require us to get a directory entry from the search results before display

Advertisements
This entry was posted in PowerShell and Active Directory. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s