We help IT Professionals succeed at work.

Creating accounts AD 2k8 PowerShell - Carriage Return in addresses

241 Views
Last Modified: 2018-12-14
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
Comment
Watch Question

Patrick BogersDatacenter platform engineer Lindows
CERTIFIED EXPERT

Commented:
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 VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

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

Open in new window

line.png
CERTIFIED EXPERT
Top Expert 2014
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Fred AcmeIT Technician

Author

Commented:
Hello !

Thank you everybody for your help.

I'll test it rapidly.
Fred AcmeIT Technician

Author

Commented:
Hello,

Your command is great !

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

Thank you !

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions