Solved

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

Posted on 2014-09-04
6
505 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 69

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
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 to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

832 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