Solved

showing in column problem

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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