Solved

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

Posted on 2014-09-04
6
481 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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 …

867 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

21 Experts available now in Live!

Get 1:1 Help Now