Creating accounts AD 2k8 PowerShell - Carriage Return in addresses

Hello,

How are you today ?

I've got a problem with Excel, PowerShell and AD (2008 or 2012).
In AD, we have some users with an address on 2 lines (See 2-LINES.JPG attached).

In Excel, I use ALT+ENTER (or "Wrap up automatically" button) to make the return (See 2-LINES-EXCEL.JPG).

Then, I save the file in csv with  coma format.

When I lauch my script (this is a part of the script) : New-ADUser -StreetAddress $_.streetaddress
The address is on a signle line.

What should I do to make the address on two lines ?

Thank you for your help !

Fred
2-lines.jpg
2-lines-Excel.jpg
Fred AcmeIT TechnicianAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick BogersDatacenter platform engineer LindowsCommented:
Hi,

In the csv you can add `r`n between the two lines like below.
"This is the first line`r`nThe Second"

Cheers
0
Shaun VermaakTechnical Specialist IVCommented:
You can also open CSV in Excel and use this formula
=SUBSTITUTE(M19,CHAR(10),"`r`n")

Open in new window

line.png
0
footechCommented:
Testing either of those solutions doesn't work for me.  PS just treats the `r`n literally and that gets put in the streetaddress attribute.

Odd thing is, I could've sworn that I had previously done an import of a multiline attribute where lines were just separated by a newline (`n), but it's not working now so my memory is probably just wrong.

When you export a multiline attribute like streetaddress to a .CSV using PS, you see that the lines are separated by <CR><LF> (`r`n).  The only way I've been able to get this to work is to do a replace operation on the imported .CSV data (which has the newline separator as in the original question).  Partial code for just the replace operation:
-StreetAddress "$($_.streetaddress -replace "\n","`r`n")"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fred AcmeIT TechnicianAuthor Commented:
Hello !

Thank you everybody for your help.

I'll test it rapidly.
0
Fred AcmeIT TechnicianAuthor Commented:
Hello,

Your command is great !

I used it yesterday and all my accounts are OK :)

Thank you !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.