Active IQ Unified Manager Discussions

Need PowerShell Help With Contents in Brackets {}

TMADOCTHOMAS
4,104 Views

Hello,

I've created Powershell scripts to export CIFS shares, iSCSI LUN mappings, and network information to CSV files. Those files are copied to a DR server so we will have configuration information available in a disaster.

 

This works well, however there are a few fields that don't transfer data to the spreadsheet. Specifically, fields that enclose data in brackets {}.

 

Here's an example: the command for exporting the list of subnets to a spreadsheet.

Get-NcNetSubnet -Controller $CLUSTER | select SubnetName,Subnet,Gateway,IPRanges | Export-Csv subnets.csv

 

When I run the command without the Export-Csv, the "IPRanges" field shows up like this in PowerShell:

{0.0.0.0-1.1.1.1}

 

With Export-Csv, it exports the results for this field like this:

System.String[]

 

I get similar results when I list network interfaces. The "DataProtocols" field encloses the results in {} which shows up wrong on the spreadsheet.

 

Has anyone run across this behavior? Is there a solution? Thanks in advance!

1 ACCEPTED SOLUTION

GidonMarcus
4,022 Views

didn't look exactly on your case - i guess it's 

http://blog.millersystems.com/powershell-exporting-multi-valued-attributes-via-export-csv-cmdlet/

 

Just to share that the way i do this type of export-import is with

ConvertTo-Json

Or

Export-CliXML

 

And then on the other site

ConverFrom-Json

OR

Import-CliXML

 

That gives very consistent data structure. and will also work with simple pipe sometimes.($Quota | Set-ncQuota)

 

i prefer the  CLIXML options. but they should both work just the same.

 

Gidi

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK

View solution in original post

2 REPLIES 2

GidonMarcus
4,023 Views

didn't look exactly on your case - i guess it's 

http://blog.millersystems.com/powershell-exporting-multi-valued-attributes-via-export-csv-cmdlet/

 

Just to share that the way i do this type of export-import is with

ConvertTo-Json

Or

Export-CliXML

 

And then on the other site

ConverFrom-Json

OR

Import-CliXML

 

That gives very consistent data structure. and will also work with simple pipe sometimes.($Quota | Set-ncQuota)

 

i prefer the  CLIXML options. but they should both work just the same.

 

Gidi

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK

TMADOCTHOMAS
3,997 Views

Thank you @GidonMarcus! The link gave me just what I needed.

Public