Read a properties file in powershell

You can use ConvertFrom-StringData to convert Key=Value pairs to a hash table:

$filedata = @'
app.name=Test App
app.version=1.2
'@

$filedata | set-content appdata.txt

$AppProps = convertfrom-stringdata (get-content ./appdata.txt -raw)
$AppProps

Name                           Value                                                                 
----                           -----                                                                 
app.version                    1.2                                                                   
app.name                       Test App                                                              

$AppProps.'app.version'

 1.2

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)