billy
July 18, 2019, 2:20pm
1
Hi,
I’m trying to read the value from a key in an ini-file, but it never works for keys in the first section.
Other keys in further sections can be retrieved without any issue.
Anyone who encountered this before?
ini-file sample:
[Settings]
DetailedLog=1
RunStatus=1
StatusPort=6090
StatusRefresh=10
Archive=1
LogFile=/opt/ecs/mvuser/MV_IPTel/log/MV_IPTel.log
Version=0.9 Build 4 Created July 11 2004 14:00
ServerName=Unknown
[FTP]
RunFTP=1
FTPPort=21
FTPDataPort=20
FTPDir=/opt/ecs/mvuser/MV_IPTel/data/FTPdata
FTP_TimeOut=5
EnableSU=1
SUUserName=mvuser
SUPassword=Avaya
[FTPS]
RunFTPS=0
FTPPort=990
FTPDataPort=889
Get-IniValue -FilePath $inifile -Section ‘Settings’ -Key ‘LogFile’
result:
[Installation] [Get-IniValue] :: Read INI Key: [Section = Settings] [Key = LogFile].
[Installation] [Get-IniValue] :: INI Key Value: [Section = Settings] [Key = LogFile] [Value = ] .
Get-IniValue -FilePath $inifile -Section ‘FTP’ -Key ‘runftp’
result:
[Installation] [Get-IniValue] :: Read INI Key: [Section = FTP] [Key = runftp].
[Installation] [Get-IniValue] :: INI Key Value: [Section = FTP] [Key = runftp] [Value = 1] .
azra1l
March 15, 2022, 3:21am
2
I am facing the same problem, but it appears i can’t receive any values at all from any section.
The fact that this is left unanswered for 3 years now doesn’t exactly give me much hope.
I am using PSADT 3.8.4 in Powershell 5.1, and right now i am running it manually from console.
Get-Content -Path .\test.ini
[Test1]
abc=123
[Test2]
xyz=Another Test
Get-IniValue -FilePath .\test.ini -Section Test1 -Key abc -ContinueOnError $true
[03-15-2022 03:59:10.186] [Initialization] [Get-IniValue] :: Read INI Key: [Section = Test1] [Key = abc].
[03-15-2022 03:59:10.192] [Initialization] [Get-IniValue] :: INI Key Value: [Section = Test1] [Key = abc] [Value = ].
Get-IniValue -FilePath .\test.ini -Section Test2 -Key xyz -ContinueOnError $true
[03-15-2022 04:23:48.370] [Initialization] [Get-IniValue] :: Read INI Key: [Section = Test2] [Key = xyz].
[03-15-2022 04:23:48.376] [Initialization] [Get-IniValue] :: INI Key Value: [Section = Test2] [Key = xyz] [Value = ].
Output doesn’t change no matter what parameters i add, i tried nearly every possible combination.
appack
March 17, 2022, 2:36pm
3
Try using single quotes ', instead of ‘ & ’
Get-IniValue -FilePath $inifile -Section 'Settings' -Key 'LogFile'