![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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> OldDog |
My System Specs![]() |
![]() |
| 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 | |||