Has anyone worked out how to get PowerShell to use app.config
files? I have a couple of .NET DLL's I'd like to use in one of my scripts but they expect their own config sections to be present in app.config
/web.config
.
Cross-referencing with this thread, which helped me with the same question: Subsonic Access To App.Config Connection Strings From Referenced DLL in Powershell Script
I added the following to my script, before invoking the DLL that needs config settings, where $configpath is the location of the file I want to load:
[appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configpath)
Add-Type -AssemblyName System.Configuration
See this post to ensure the configuration file specified is applied to the running context.