Effective December 3, NetApp adopts Microsoft’s Business-to-Customer (B2C) identity management to simplify and provide secure access to NetApp resources.
For accounts that did not pre-register (prior to Dec 3), access to your NetApp data may take up to 1 hour as your legacy NSS ID is synchronized to the new B2C identity.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Active IQ Unified Manager Discussions

Need PowerShell Help With Contents in Brackets {}

TMADOCTHOMAS

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

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

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

TMADOCTHOMAS

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

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public