Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Export to CSV Problem

Reply
 
Old 07-30-2008   #1 (permalink)
OldDog


 
 

Export to CSV Problem

Hi,

I have a script that writes out data from two sources to the host.
What I would like to do is write the data to a CSV file. Here is what
I have so far.

$customer = Get-PHCustomer -SystemSN $UserSystemSN;
$timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit
$UserLimit;
foreach($time in $timeObj){
$resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem
FCPTransport -Table FCPTransLocal |
Where-Object {$_.ConnectionType -eq 6};
$resParesdObj | Select-Object ($customer.CustomerName),
($customer.SystemSN),$_.conti,$_.lldeviceid,$_.ConnectionType,
($time.LogTime) |
Export-Csv FCTopology.csv |

ft @{l="Customer Name";e={$customer.CustomerName}},
@{l="System SN";e={$customer.SystemSN}},
@{l="Controller";e={$_.conti}},
@{l="LLDevice ID";e={$_.lldeviceid}},
@{l="Connection Type";e={$_.ConnectionType}},
@{l="Log Time";e={$time.LogTime}} -autosize;


The problem is that $customer.CustomerName, $customer.SystemSN and
$time.LogTime do not show up in the CSV file.

Here is the error;

ERROR: Select-Object : Cannot convert System.Int64 to one of the
following types......

TIA

Olddog

My System SpecsSystem Spec
Old 07-30-2008   #2 (permalink)
Shay Levy [MVP]


 
 

Re: Export to CSV Problem

Hi OldDog,

Can you print the values of $customer right after its declartion:

$customer = Get-PHCustomer -SystemSN $UserSystemSN
$customer.CustomerName
$customer.SystemSN


What this gives :

$timeObj | foreach { $_.LogTime }


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic



O> Hi,
O>
O> I have a script that writes out data from two sources to the host.
O> What I would like to do is write the data to a CSV file. Here is what
O> I have so far.
O>
O> $customer = Get-PHCustomer -SystemSN $UserSystemSN;
O> $timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit
O> $UserLimit;
O> foreach($time in $timeObj){
O> $resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem
O> FCPTransport -Table FCPTransLocal |
O> Where-Object {$_.ConnectionType -eq 6};
O> $resParesdObj | Select-Object ($customer.CustomerName),
O> ($customer.SystemSN),$_.conti,$_.lldeviceid,$_.ConnectionType,
O> ($time.LogTime) |
O> Export-Csv FCTopology.csv |
O> ft @{l="Customer Name";e={$customer.CustomerName}},
O> @{l="System SN";e={$customer.SystemSN}},
O> @{l="Controller";e={$_.conti}},
O> @{l="LLDevice ID";e={$_.lldeviceid}},
O> @{l="Connection Type";e={$_.ConnectionType}},
O> @{l="Log Time";e={$time.LogTime}} -autosize;
O> The problem is that $customer.CustomerName, $customer.SystemSN and
O> $time.LogTime do not show up in the CSV file.
O>
O> Here is the error;
O>
O> ERROR: Select-Object : Cannot convert System.Int64 to one of the
O> following types......
O>
O> TIA
O>
O> Olddog
O>


My System SpecsSystem Spec
Old 07-30-2008   #3 (permalink)
Shay Levy [MVP]


 
 

Re: Export to CSV Problem



Didn't see the last line where you show the error. What if you enclose the
varibales in {} insted of () ?

Can you also check if this works:


$customer = Get-PHCustomer -SystemSN $UserSystemSN
$timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit $UserLimit

$timeObj | foreach {

$time = $_

$CustomerName = @{n="Customer Name";e={$customer.CustomerName}}
$SystemSN = @{n="System SN";e={$customer.SystemSN}}
$Controller = @{n="Controller";e={$_.conti}}
$LLDeviceID = @{n="LLDevice ID";e={$_.lldeviceid}}
$Connection = @{n="Connection Type";e={$_.ConnectionType}}
$LogTime = @{n="Log Time";e={$time.LogTime}}

$resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem FCPTransport
-Table FCPTransLocal | where {$_.ConnectionType -eq 6}
$resParesdObj | Select $CustomerName,$SystemSN,$Controller,$LLDeviceID,$Connection,$LogTime

} | Export-Csv FCTopology.csv



---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic



O> Hi,
O>
O> I have a script that writes out data from two sources to the host.
O> What I would like to do is write the data to a CSV file. Here is what
O> I have so far.
O>
O> $customer = Get-PHCustomer -SystemSN $UserSystemSN;
O> $timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit
O> $UserLimit;
O> foreach($time in $timeObj){
O> $resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem
O> FCPTransport -Table FCPTransLocal |
O> Where-Object {$_.ConnectionType -eq 6};
O> $resParesdObj | Select-Object ($customer.CustomerName),
O> ($customer.SystemSN),$_.conti,$_.lldeviceid,$_.ConnectionType,
O> ($time.LogTime) |
O> Export-Csv FCTopology.csv |
O> ft @{l="Customer Name";e={$customer.CustomerName}},
O> @{l="System SN";e={$customer.SystemSN}},
O> @{l="Controller";e={$_.conti}},
O> @{l="LLDevice ID";e={$_.lldeviceid}},
O> @{l="Connection Type";e={$_.ConnectionType}},
O> @{l="Log Time";e={$time.LogTime}} -autosize;
O> The problem is that $customer.CustomerName, $customer.SystemSN and
O> $time.LogTime do not show up in the CSV file.
O>
O> Here is the error;
O>
O> ERROR: Select-Object : Cannot convert System.Int64 to one of the
O> following types......
O>
O> TIA
O>
O> Olddog
O>


My System SpecsSystem Spec
Old 07-30-2008   #4 (permalink)
OldDog


 
 

Re: Export to CSV Problem

On Jul 30, 11:27*am, Shay Levy [MVP] <n...@xxxxxx> wrote:
Quote:

> Didn't see the last line where you show the error. What if you enclose the
> varibales in {} insted of () ?
>
> Can you also check if this works:
>
> $customer = Get-PHCustomer -SystemSN $UserSystemSN
> $timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit $UserLimit
>
> $timeObj | foreach {
>
> * * * * $time = $_
>
> * * * * $CustomerName = @{n="Customer Name";e={$customer.CustomerName}}
> * * * * $SystemSN = @{n="System SN";e={$customer.SystemSN}}
> * * * * $Controller = @{n="Controller";e={$_.conti}}
> * * * * $LLDeviceID = @{n="LLDevice ID";e={$_.lldeviceid}}
> * * * * $Connection = @{n="Connection Type";e={$_.ConnectionType}}
> * * * * $LogTime = @{n="Log Time";e={$time.LogTime}}
>
> * * * * $resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem FCPTransport
> -Table FCPTransLocal | where {$_.ConnectionType -eq 6}
> * * * * $resParesdObj | Select $CustomerName,$SystemSN,$Controller,$LLDeviceID,$Connection,$LogTime
>
> } | Export-Csv FCTopology.csv
>
> ---
> Shay Levy
> Windows PowerShell MVPhttp://blogs.microsoft.co.il/blogs/ScriptFanatic
>
> O> Hi,
> O>
> O> I have a script that writes out data from two sources to the host.
> O> What I would like to do is write the data to a CSV file. Here is what
> O> I have so far.
> O>
> O> $customer = Get-PHCustomer -SystemSN $UserSystemSN;
> O> $timeObj = Get-PHParsedTime -SystemSN $UserSystemSN -Limit
> O> $UserLimit;
> O> foreach($time in $timeObj){
> O> $resParesdObj = Get-PHParsedData -SetID $time.SetId -Subsystem
> O> FCPTransport -Table FCPTransLocal |
> O> Where-Object {$_.ConnectionType -eq 6};
> O> $resParesdObj | Select-Object ($customer.CustomerName),
> O> ($customer.SystemSN),$_.conti,$_.lldeviceid,$_.ConnectionType,
> O> ($time.LogTime) |
> O> Export-Csv FCTopology.csv |
> O> ft @{l="Customer Name";e={$customer.CustomerName}},
> O> @{l="System SN";e={$customer.SystemSN}},
> O> @{l="Controller";e={$_.conti}},
> O> @{l="LLDevice ID";e={$_.lldeviceid}},
> O> @{l="Connection Type";e={$_.ConnectionType}},
> O> @{l="Log Time";e={$time.LogTime}} -autosize;
> O> The problem is that $customer.CustomerName, $customer.SystemSN and
> O> $time.LogTime do not show up in the CSV file.
> O>
> O> Here is the error;
> O>
> O> ERROR: Select-Object : Cannot convert System.Int64 to one of the
> O> following types......
> O>
> O> TIA
> O>
> O> Olddog
> O>
Well That worked! Not sure why, But thanks!!!!!

OldDog
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Mail Export/Import Problem Browsers & Mail
Export Import Problem Vista mail
Live Contacts Export Problem Live Mail
using export-csv to export to multiple CSV files PowerShell
Export-CliXml/Export-Csv: Change to Export-Object? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46