I want to execute my script with command line. I use function inside my script.
I used this script:
Function Get-IniFile
{
Param(
[parameter(mandatory=$true)][string]$FilePath
)
$input_file = $FilePath
$ini_file = @{}
Get-Content $input_file | ForEach-Object {
$_.Trim()
} | Where-Object {
$_ -notmatch '^(;|$)'
} | ForEach-Object {
if ($_ -match '^\[.*\]$') {
$section = $_ -replace '\[|\]'
$ini_file[$section] = @{}
} else {
$key, $value = $_ -split '\s*=\s*', 2
$ini_file[$section][$key] = $value
}
}
$Get = $ini_file.Class.Amount
$Get
}
I execute this script from command line with this command:
PowerShell.ps1 Get-IniFile -FilePath
I dont get any result when I execute this code, but If I remove "Function Get-IniFile" I got the value of Amount.
This is my INI file
[Class]
Amount = 1000
Feature = 20
[Item]
Set = 100
Return = 5