Solved

showing in column problem

Posted on 2012-03-28
3
432 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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scannerā€¦
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ā€¦

733 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