Update Notes in Active Directory account with powershell

I want to add some information to the Notes section in the Telephone tab. I can do it with the code below but that replaces what is already there .. I don't want to replace it .. I need this information to be the first or last line of what ever information is already there ..

What are the other options ? -Add does not work and I tried other options and none work and cant figure out the help on set-aduser

help ??

This is what I was testing with..

GC C:\PS\Users.txt | % {
$info = "My Notes Here"
Set-ADUser $_ -replace @{info=$info}
}
LVL 2
MilesLoganAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SubsunConnect With a Mentor Commented:
You can try this and see if it works as expected..
GC C:\PS\Users.txt | % {
$note = (Get-ADUser $_ -Properties info).info
$info = "My Notes Here"
If ($note -ne $null){
 Set-ADUser $_ -replace @{info="$note`r`n$info"}
 }Else{
 Set-ADUser $_ -replace @{info=$info}
 }
}

Open in new window

0
 
MilesLoganAuthor Commented:
SubSun .. thank you so much again !
0
 
SubsunCommented:
You are welcome!!
0
 
B YCommented:
Is there anyway to append to the top instead of the bottom?
0
All Courses

From novice to tech pro — start learning today.