Reputation: 695
This is strictly a learning experience:
I have a .CSV file that I'm using to define my deployment environments. One of the variables has to be in a Hash Table format.
Can anyone come up with a clever way to put it all in one line? Right now I harvest them as a string from CSV, conver to array, convert array to hash table.
Simplified code:
Foreach($i in $DefaultCSV){...
$App_Fabric_Hosts_a = $i.App_Fabric_Hosts.split(",")}
$App_Fabric_Hosts_h = @{}
foreach($r in $App_Fabric_Hosts_a){$App_Fabric_Hosts_h.add($r,"22233")}
Upvotes: 0
Views: 3608
Reputation: 695
This is the best I came up with:
$d=@{};foreach($r in $DefaultCSV[$arrayposition].app_fabric_hosts.split(",")){$d.add($r,"22233")}
Upvotes: 1