Giter Site home page Giter Site logo

woznet / convert-ini Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeiannone/convert-ini

0.0 0.0 0.0 644 KB

A PowerShell module for parsing, converting, and managing ini file properties

License: GNU General Public License v3.0

C# 20.37% PowerShell 79.63%

convert-ini's Introduction

Convert-Ini

Tests

A PowerShell module for parsing, converting, and managing ini file properties

You can find the latest releases and downloads for this module in the PowerShell Gallery: https://www.powershellgallery.com/packages/IniConverter

Installation

PS > Install-Module -Name IniConverter

Exported PowerShell Functions:

  • ConvertFrom-Ini
  • ConvertTo-Ini
  • Add-IniProperty
  • Remove-IniProperty

Examples:

ConvertFrom-Ini
PS > $ini = "
>> Language=Powershell
>> Name=Joe
>> [Address]
>> ZIP=19147
>> Street=123 Fitzwater Street
>> State=Pennsylvania
>> "
PS > $obj = $ini | ConvertFrom-Ini
PS > $obj


Language   Name Address
--------   ---- -------
Powershell Joe  @{ZIP=19147; Street=123 Fitzwater Street; City=Philadelphia; State=Pennsylvania}


PS > $obj.Name
Joe
PS > $obj.Address.Street
123 Fitzwater Street
PS >
PS > $obj1 = Get-Content .\Config.ini | ConvertFrom-Ini
PS > $obj2 = Get-Content -Raw .\Config.ini | ConvertFrom-Ini
PS > $obj3 = ConvertFrom-Ini -InputObject (Get-Content .\Config.ini)
ConvertTo-Ini
PS > $obj = @{
>> Name = 'Joe'
>> Language = 'PowerShell'
>> Address = @{
>>      Street = '123 Fitzwater Street'
>>      City = 'Philadelphia'
>>      State = 'Pennsylvania'
>>      ZIP = 19147
>>   }
>> }
PS > $ini = $obj | ConvertTo-Ini
PS > $ini > Config.ini
PS > type .\Config.ini
Name=Joe
Language=PowerShell

[Address]
ZIP=19147
Street=123 Fitzwater Street
State=Pennsylvania
City=Philadelphia

PS >
Add-IniProperty
PS > type .\test.ini
Test1 = hello
Test2 = world

[TestSection]
test1 = hello
test2 = world

PS > $myobj = @{ TestSection = @{ test1 = "updated"; }; TestSection2 = @{ hello = "world"; } }
PS > .\test.ini | Add-IniProperty -InputObject $myobj
PS > type .\test.ini
Test1 = hello
Test2 = world

[TestSection]
test1 = updated
test2 = world

[TestSection2]
hello = world

PS >
Remove-IniProperty
PS > type .\test.ini
Test1 = hello
Test2 = world

[TestSection]
test1 = updated
test2 = world

[TestSection2]
hello = world

PS > .\test.ini | Remove-IniProperty -Section "TestSection" -Property "test1"
PS > .\test.ini | Remove-IniProperty -Section "TestSection2"
PS > .\test.ini | Remove-IniProperty -Property "Test2"
PS > type .\test.ini
Test1 = hello

[TestSection]
test2 = world

PS >

convert-ini's People

Contributors

joeiannone avatar woznet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.