I'm trying to read the text files that are generated from another program and parse them to perform other actions.
This topic is close but the file I'm reading has more "structuring" for lack of a better word. Here is a sample of what the file I am reading will look like for reference:
data:extend(
{
{
type = "buildformula",
name = "item1",
active = false,
buildtime = 3,
ingredients =
{
{"ingredient1", 1},
{"ingredient2", 4},
{"ingredient3", 5}
},
result = "finished item 1"
},
{
type = "buildformula",
name = "item2",
active = true,
buildtime = 12,
ingredients =
{
{"ingredient1", 2},
{"ingredient2", 3}
},
result = "finished item 2"
},
}
)
One other suggestion in that post referenced ConvertFrom-String command which seems to have the power I need but i'm still getting no results.
Lastly here is the most recent code I have :
$TemplateAdr = @'
{
type = "buildformula",
name = "item1",
active = false,
buildtime = 3,
ingredients =
{
{"ingredient1", 1},
{"ingredient2", 4},
{"ingredient3", 5}
},
result = "finished item 1"
},
{
type = "buildformula",
name = "item2",
active = true,
buildtime = 12,
ingredients =
{
{"ingredient1", 2},
{"ingredient2", 3}
},
result = "finished item 2"
},
'@
$output=Get-Content -Path "C:\temp\itembuilds.txt" | ConvertFrom-String -TemplateContent $TemplateAdr
I'm new to PowerShell but I feel like this is possible.