Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

showing in column problem

Posted on 2012-03-28
3
Medium Priority
?
435 Views
Last Modified: 2012-04-02
hello,
I'm trying to get a list of computers from Active Directory and send it as email to some people.
with
Get-ADComputer -filter * -searchbase "ou=computers,dc=domain,dc=com" | foreach { $_.name }

I get the following result (in a column)
computer1
computer2

when I set this to a variable and get the output to the variable with
$list = Get-ADComputer -filter * -searchbase "ou=computers,dc=domain,dc=com" | foreach { $_.name }
write-host $list

I get the below result (in a row)
computer1 computer2

is there a way to show this as it's original state (in a column)
computer1
computer2


thank you
0
Comment
Question by:TAI-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
TAI- earned 0 total points
ID: 37775374
hello,
found out that I have to use out-string,
it seems to be working
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37779031
Out-String? can't say i've ever used that before.

I would do it like this:

$list = Get-ADComputer -filter * -searchbase "ou=computers,dc=domain,dc=com"
$list | Select Name

Open in new window


Should work anyways.
0
 

Author Closing Comment

by:TAI-
ID: 37795238
outstring work perfectly in one row
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question