Solved

Powershell Script, I need to add a comma between the results

Posted on 2014-09-04
6
473 Views
Last Modified: 2014-09-04
I have this script that I found and it works.  But I need to have a comma between the name attribute and the managedby attribute.  The result is in csv format but it is all in one cell.  Not sure how to make it work.  Here is the PS cmdlets

$test = 'OU=test,DC=mydomain,DC=int'
$test | ForEach {Get-ADComputer -Filter * -Properties ManagedBy -SearchBase $_ } |
 Select Name, ManagedBy |
 Sort -Property Name |
 Out-File C:\test.csv

Your help is much appreciated.
0
Comment
6 Comments
 
LVL 37

Accepted Solution

by:
Neil Russell earned 500 total points
ID: 40304630
Use Export-csv instead
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40304639
You can use Export-Csv to export the details to a csv file..
$test = 'OU=test,DC=mydomain,DC=int'
$test | ForEach {Get-ADComputer -Filter * -Properties ManagedBy -SearchBase $_ } | 
Select Name, ManagedBy |
Sort -Property Name |
Export-Csv C:\test.csv -nti

Open in new window

Refer : http://technet.microsoft.com/en-us/library/ee176825.aspx
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40304810
Note that Export-CSV will enclose all values in double quotes. Since you are talking about "cells", I assume you import the CSV file into Excel - than the double quotes do not matter.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4
ID: 40304836
I can't believe that it was that simple.  I guess it's not simple if you really don't know all the functionality.  That worked.  I appreciate all your help.  Thank you Subsun, as you have been instrumental in my Powershell learning.  To be fair, ( and not get in trouble)  I will award the points to Neilsr as he came in first with the working solution.

Thanks again.
0
 
LVL 4

Author Closing Comment

by:get-ADuser -F ($_.Name -eq "Todd")
ID: 40304838
Very much appreciated.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40304876
No problem... You could also accept multiple comments as answer and split points (assist)  if the experts comments are helpful..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now