Solved

How to remove #TYPE System.String when converting to CSV ?

Posted on 2013-01-15
4
2,076 Views
Last Modified: 2013-01-15
I have the following code:

Get-Content C:\scripts\AD\temp\UPI_OUv2.xlsx| ConvertTo-Csv > C:\scripts\AD\temp\UPI_OUv2.csv

Open in new window


How do i remove the #TYPE System.String in the CSV file ?

Thanks,
0
Comment
Question by:namerg
  • 2
4 Comments
 
LVL 9

Expert Comment

by:David Carr
Comment Utility
Try using Select-Object with the properties you want and Export-CSV instead of ConvertTo-CSV and add –NoTypeInformation

eg  | select property1,property2 | Export-Csv -Path C:\scripts\AD\temp\UPI_OUv2.csv –NoTypeInformation
0
 

Author Comment

by:namerg
Comment Utility
And property1, property2 are the headers of the CSV file ?
0
 
LVL 9

Assisted Solution

by:David Carr
David Carr earned 250 total points
Comment Utility
Those would be the values that you want from the excel file. It is the -NoType Information that removes it from your CSV File

you might be able to get it with just Export-Csv -Path C:\scripts\AD\temp\UPI_OUv2.csv –NoTypeInformation

I do not have Excel files to test with at the moment
0
 
LVL 40

Accepted Solution

by:
Subsun earned 250 total points
Comment Utility
It you are trying to read xlsx file in PoweShell then you can use Import-Excel function as I mentioned in you other question..
http://podlisk.wordpress.com/2011/11/20/import-excel-spreadsheet-into-powershell/
0

Featured Post

Highfive Gives IT Their Time Back

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!

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Set OWA language and time zone in Exchange for individuals, all users or per database.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

12 Experts available now in Live!

Get 1:1 Help Now