Monthly Archive

Add to Notes field

You may need to add extra information to the notes field

$ou = "OU=BlogTests,DC=Manticore,DC=org"            
            
$extra = @"

Just a bit more info
"@             
            
"`nMicrosoft"            
$name = "UserA"            
$p = Get-ADUser -Identity $name -Properties *            
$note = $p.info + $extra            
Set-ADUser -Identity $name -Replace @{info = $note}            
            
"`nAD provider"            
$name = "UserB"            
$dn = "cn=$name,$ou"            
$p = Get-ItemProperty -Path AD:\$dn  -Name info             
$note = $p.info + $extra            
Set-ItemProperty -Path AD:\$dn  -Name info -Value $note  -Force            
             
"`nQuest"            
$name = "UserC"            
$p = Get-QADUser -Identity $name -IncludeAllProperties            
$note = $p.info + $extra            
Set-QADUser  -Identity $name -ObjectAttributes @{info=$note}            
            
"`nScript"            
$name = "UserD"            
$dn = "cn=$name,$ou"            
$user = [adsi]"LDAP://$dn"            
            
$note = @"
$($user.info)

$($extra)
"@            
$user.info = $note            
$user.SetInfo()

The Microsoft & Quest cmdlets together with the provider all work in the same way. Get the current attribute value, use string concatenation to add the extra info and write back to AD

The script is slightly different in that we have to create a new here-string by substituting the current value and the new info. The combined data can be written back to AD.  If you try to  use ordinary string concatenation you will get a “The specified directory service attribute or value already exists.” error.

Leave a Reply