We have some config parms in our BizTalk config file. I'd like to access them in PowerShell using System.ConfigurationManger, rather than writing a custom function to parse the xml and do it.
I'm trying what is described in this blog: https://www.c-sharpcorner.com/blogs/load-and-read-config-files-in-powershell
I might be hitting what this describes: ConfigurationManager.AppSettings getting null?
cls
$configPath = "d:\Program Files (x86)\Microsoft BizTalk Server 2016\BTSNTSvc.exe.config"
[appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configpath)
$verifyConfig = [appdomain]::CurrentDomain.GetData("APP_CONFIG_FILE")
Write-Host "verifyConfig=$verifyConfig"
$resultObj = [System.Configuration.ConfigurationManager]::AppSettings["Office365_Token_ClientID"]
$resultObj.GetType
if ($resultObj -eq $null)
{
Write-Host "Result = null"
}
else
{
$result = $resultObj.ToString()
write-host "Result = $result"
}
Trying to pick up this value:
<add key="Office365_Token_ClientID" value="xxx" />
The result is the "Result = null" from the Write-Host.