PowerShell to Read single value from simple .ini file
ini, powershell
Solution
This looks like a good use case for `ConvertFrom-StringData` which by default looks for key value pairs separated by the equals symbol.
Because the first line of your .ini file doesn't have an equals we would need to skip it to avoid an error. This can be done simply with `Select -Skip 1`.
Here's the code:
$ADAP = Get-Content 'ADAP.ini' | Select -Skip 1 | ConvertFrom-StringData
You can then get the values of APP and DLL by accessing them as named properties of the `$ADAP` object, as follows:
$ADAP.APP
$ADAP.DLL
Problem
Everything I've found looks way over complex. It's almost like I just need to read a text file. ADAP.ini contains this, nothing else: ``` http://xxx.104.xxx.226 APP=2.3.6 DLL=2.3.6 ``` Using Powershell, how can I read what APP=value is? and or what DLL=value is? I would store the value in a variable and use it later in Powershell script.