I try to make a program that gets variables from an external file. My problem is that company policy doesn't allow users to run ps1 files (the program works because I compile the ps1 into an exe by ps2exe), so this external file must be a txt, csv, or something other plain text format. I don't want to burn these variables into the exe, because the users need some flexibility with the values they use.
I tried to make a hashtable and get the variables into it by ConvertFrom-StringData, but that messes up the output.
file.txt
one = foo
two = bar
prog.ps1
$variable = Get-Content ".\file.txt" | Out-String | ConvertFrom-StringData
Write-Host $variable.one
Write-Host "$variable.two"
The latter one shows up as: System.Collections.Hashtable.two instead of the value of $variable.two. Of course, in this simplified example there wasn't really need for the quotation marks around the second variable, but this program needs it at some places.
When I stored the variables with their correct format in a ps1 file, and inculded it the normal
. .\file.ps1
way, it worked like it should, but it can't be used by the users who need it.
I would appreciate any ideas of how to make it work. I mean if it's possible at all.