Avatar of Fred Acme
Fred Acme
 asked on

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
PowershellActive DirectoryMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Fred Acme

8/22/2022 - Mon
Patrick Bogers

Hi,

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

Cheers
Shaun Vermaak

You can also open CSV in Excel and use this formula
=SUBSTITUTE(M19,CHAR(10),"`r`n")

Open in new window

line.png
ASKER CERTIFIED SOLUTION
footech

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Fred Acme

ASKER
Hello !

Thank you everybody for your help.

I'll test it rapidly.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Fred Acme

ASKER
Hello,

Your command is great !

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

Thank you !