How to write a nested arbitrary associative array value set to a .psd1 file in powershell?

I have a powershell array object that is programmatically generated, something with arrays inside arrays, inside arrays, sometimes called a “property bag” or “hash table”, but I think it's originally called an array containing arrays, in the most native powershell terminology.

For instance:

 @{
 Version  = '1.0.0'
 Name     = 'thing'
 Revision = 'c3a89cd20e19bb82f41e95e0806edc5b6cfd224e'
 Date     = '2016-12-09'
 Build    = '1234'
 Contents = @{
      "index.html" = "23dd7b993f40bb3ae8848fe104b3b767"
 }
 }

Creating a function to save only one specific set of content in a .PSD1 file seems not enough general. I want to save this exact array structure in memory to a PSD1 file. Is there any built-in way in Powershell to store a variable in memory with the values ​​above? "Opposite function Import-PowershellDataFile. " I would suggest that it will be called Export-PowershellDatafile, but such a function does not exist.

+4
source share

Source: https://habr.com/ru/post/1663549/


All Articles