MilesLogan
asked on
Copy Description data to info field for multiple active directory accounts
HI EE
I am needing to copy the data in the Description field to the info field ..
Trying to recycle and other scripts but I can't seem to get it .. below is as far as I got but I get no results or errors .
$users = import-csv .\CopytoTel.txt
ForEach ($user in $users) {
$Description = (Get-ADUser $user -Properties Description)
Set-ADUser $user -replace @{info="$Description `r`n$Description"}
}
I am needing to copy the data in the Description field to the info field ..
Trying to recycle and other scripts but I can't seem to get it .. below is as far as I got but I get no results or errors .
$users = import-csv .\CopytoTel.txt
ForEach ($user in $users) {
$Description = (Get-ADUser $user -Properties Description)
Set-ADUser $user -replace @{info="$Description `r`n$Description"}
}
ASKER
thank u , I will test ..
I need to copy the information in the description field to the telephone tab " info " field
not for all users , just a couple thousand
I need to copy the information in the description field to the telephone tab " info " field
not for all users , just a couple thousand
ASKER
Hi David
Neither option had the result I need .
script 1) it deleted what was in the Notes "info" field and it entered two lines with @[description=testdata}
testdata is what is in the description field of my test account , not what was entered in the csv file .
script2) which is the option I rather use, deleted what was in the Notes "info" field and it entered the test account DN two times .
I need to copy from a list of users what is in the description to the Notes "info" field as a new line , leaving what is already there .
thank you !
Neither option had the result I need .
script 1) it deleted what was in the Notes "info" field and it entered two lines with @[description=testdata}
testdata is what is in the description field of my test account , not what was entered in the csv file .
script2) which is the option I rather use, deleted what was in the Notes "info" field and it entered the test account DN two times .
I need to copy from a list of users what is in the description to the Notes "info" field as a new line , leaving what is already there .
thank you !
I guess "$Description `r`n$Description" is an error, as you most probably do not want to copy the description twice.
And you didn't answer the (implicit) question about the CSV format. I assume it is just the name, without any column header?
And you didn't answer the (implicit) question about the CSV format. I assume it is just the name, without any column header?
$users = Get-Content .\CopytoTel.txt
ForEach ($user in $users) {
$Description = (Get-ADUser $user -Properties Description).Description
if ($Description) { Set-ADUser $user -replace @{info=$Description} }
}
or more PowerShellish. as I would do:Get-Content .\CopytoTel.txt |
Get-ADUser -Properties Description |
? { $_.Description } |
% { Set-ADUser $_ -Replace @{info=$_.Description} }
Note that you have to make sure Description is not empty, othewise Set-ADUser will throw an error. I've added checks to both scripts.
ASKER
Hi Qlemo
both of these work but delete the data that is already in the info field , I need to keep the data that is already there .
what I can modify to keep the data in the info field ?
If I can get your options to work , I don't need the CSV option ..
the CSV option would be SamAccountName,Description but if your options work , I don't need to pull the data and then update through a CSV ,
both of these work but delete the data that is already in the info field , I need to keep the data that is already there .
what I can modify to keep the data in the info field ?
If I can get your options to work , I don't need the CSV option ..
the CSV option would be SamAccountName,Description
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Qlemo
This did exactly what I needed .. thank you so much for your help .. Happy Holidays
This did exactly what I needed .. thank you so much for your help .. Happy Holidays
users,Description
username1,This is the description
Open in new window
What are you really trying to do?