Solved

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

Posted on 2013-01-15
4
2,158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:David Carr
ID: 38780163
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
ID: 38780240
And property1, property2 are the headers of the CSV file ?
0
 
LVL 9

Assisted Solution

by:David Carr
David Carr earned 250 total points
ID: 38780286
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
ID: 38780339
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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