KK99
KK99

Reputation: 1989

How can I parse and get values from this INI file using Powershell

My INI (config.ini) file looks like below

#this is comment
[Folder]
C:\temp
C:\dir1
C:\dir2

How can I get the content of [Folder] using powershell?

I need the folder path in an array

The example I've seen are with name value pairs

Upvotes: 0

Views: 2031

Answers (1)

CB.
CB.

Reputation: 60958

Using your example config.ini:

[System.Collections.ArrayList]$a = GC .\CONFIG.INI
[string[]]$b=$a.GetRange( $a.IndexOf("[Folder]")+1, ( $a.Count - ($a.IndexOf("[Folder]")+1)))
$b
C:\temp
C:\dir1
C:\dir2

Upvotes: 1

Related Questions