Got a bit of a query regarding loading a type that depends on a configuration file in PowerShell; I know you can load the file on the fly using the below with a fully qualified path:
[System.AppDomain]::CurrentDomain.SetData('APP_CONFIG_FILE', $appConfigPath.Path)
This is all fine and dandy; however the configuration file references other configuration files, which aren't loaded. File structure of my project like so:
- -MyPowerShellScript.ps1
- -app.config (with references to the configuration files in the ~/Config directory)
- -Config
- --Other configuration files
The other configuration files are referenced like so in the app.config (Examine is the type that's throwing the exception regarding missing configuration, actually):
<Examine configSource="config\ExamineSettings.config" />
Since PowerShell runs under ~\Windows\System32\WindowsPowerShell\v1.0, how would I go about loading these extraneous configuration files into the current domain? Is this even possible or do I need to really re-think this? I even tried pasting the files directly into the PowerShell folder, which is pretty horrible!
Cheers - Mike