Skip to content
/ PsIni Public
forked from lipkau/PsIni

Work with INI files in PowerShell using hashtables

License

Notifications You must be signed in to change notification settings

DevSeq/PsIni

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub release Build status PowerShell Gallery License

Table of Contents

Description

Work with INI files in PowerShell using hashtables.

Origin

This code was originally a blog post for Hey Scripting Guy

Use PowerShell to Work with Any INI File

Installation

PsIni is published to the Powershell Gallery and can be installed as follows:

Install-Module PsIni

Examples

Create a hashtable and save it to C:\settings.ini:

Import-Module PsIni
$Category1 = @{"Key1"="Value1";"Key2"="Value2"}
$Category2 = @{"Key1"="Value1";"Key2"="Value2"}
$NewINIContent = @{"Category1"=$Category1;"Category2"=$Category2}
Out-IniFile -InputObject $NewINIContent -FilePath "C:\settings.ini"

Results:

[Category1]
Key1=Value1
Key2=Value2

[Category2]
Key1=Value1
Key2=Value2

Returns the key "Key2" of the section "Category2" from the C:\settings.ini file:

$FileContent = Get-IniContent "C:\settings.ini"
$FileContent["Category2"]["Key2"]

Authors/Contributors

Author

Contributor

About

Work with INI files in PowerShell using hashtables

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%