h41msh1c0r
Goto Top

Powershell INI Tags auslesen

Hi@All,

Vorgabe INI.

[bereich1]
...
[bereich2]
...
[bereich3]
...

Aus dem File will ich die Namen der Bereiche auslesen und in einen String packen mit ";" als Delemiter.

Result= "bereich1;bereich2;bereich3"  

Mein Erster Versuch schlägt schonmal fehl. =)

$inifile = "c:\temp\vorgabe.ini"  
$result = ""  

get-content -path $inifile | foreach{ 
  if($_ -like "[*]"){  
    $result += ";"+$_  
  }
}

Da er mir nichts liefert und auch keinen Fehler wirft wird mein Gedanke wohl falsch sein.

F1 ^^

Gruß

Content-Key: 317446

Url: https://administrator.de/contentid/317446

Printed on: May 7, 2024 at 14:05 o'clock

Mitglied: 131026
Solution 131026 Oct 11, 2016 updated at 11:05:33 (UTC)
Goto Top
$result = (gc "c:\temp\vorgabe.ini" | ?{$_ -match '^\[([^\]]+)\]'} | %{$matches[1]}) -join ";"  
By the way:
Get-IniContent

R.
Member: H41mSh1C0R
H41mSh1C0R Oct 11, 2016 at 11:18:17 (UTC)
Goto Top
Hi Ranger,

danke für die fixe Hilfe.

Gruß