I am trying to read an INI file from a web site. Within that INI file are sections that have dashes in them. I need to be able to read several sections so I can locate specific files to download referenced within the INI files. I found a script for parsing INI files, but when I run it, the script fails to handle the sections that have dashes. Any ideas on how I can work around the issue?
$Web = New-Object System.Net.WebClient
Function Get-INIContent ($ContentList){
$INI = @()
Switch -regex ($contentList)
{"^\[(.+)\]"
{
[string]$Section = $Matches[1]
$INI[$Section] = @{}
$CommentCount = 0
}
}
}
$ContentList = $Web.Downloadstring("http://download.nai.com/PRODUCTS/COMMONUPDATER/avvdat.ini")
Get-INIContent $contentlistWhat I was hoping to do was search through the INI until I found the sections I want, and then read the fields for that section so I know what to download. I won't be pulling all of the files, so I need to find a way to search for the sections I am looking for then read all of the lines for that section and process them.