Using CSV to Create Objects

by Oct 4, 2018

Sometimes it may be clever to use simple text-based CSV format internally to bulk-create objects, especially if the original data is already text-based and may need just a little reformatting.

Here is a simple example that takes information and creates a list of custom objects this way:

$text = 'Name,FirstName,Location

$objects = $text | ConvertFrom-Csv

$objects | Out-GridView

The result looks similar to this:

Name    FirstName Location
----    --------- --------
Weltner Tobias    Germany 
Nikolic Aleksandar Serbia  
Snover  Jeffrey   USA     
Special ÄÖÜß      Test  

Twitter This Tip! ReTweet this Tip!