Solved

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

Posted on 2013-01-15
4
2,096 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
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sccm client without collection 1 40
Delete email from user mailbox 23 76
Optimize find and replace on 194 MB text file 20 41
powershell return the value of a Reg_dword 3 36
Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
Utilizing an array to gracefully append to a list of EmailAddresses
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

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