8000 GitHub - colinbate/PsIni: Persist a PowerShell hashtable as an INI file. · GitHub
[go: up one dir, main page]

Skip to content
colinbatePublic
forked from lipkau/PSIni

About

Persist a PowerShell hashtable as an INI file.

Resources

Stars

0 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PsIni Join the chat at https://gitter.im/lipkau/PsIni

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

The individual functions have been published to Miscrosoft's Script Gallery:

Examples

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

  PS> Import-Module PsIni
  PS> $Category1 = @{"Key1"="Value1";"Key2"="Value2"}
  PS> $Category2 = @{"Key1"="Value1";"Key2"="Value2"}
  PS> $NewINIContent = @{"Category1"=$Category1;"Category2"=$Category2}
  PS> 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:

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

Contributors

About

Persist a PowerShell hashtable as an INI file.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0