Storing configuration in *exe.config file

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
TimoNieland
Posts: 1
Last visit: Fri Feb 18, 2022 3:02 pm

Storing configuration in *exe.config file

Post by TimoNieland »

Product, version and build: PowerShell Studio 2016 (5.3.130.0)
32 or 64 bit version of product: x64
Operating system: Windows Server 2012 R2
32 or 64 bit OS: x64
PowerShell Version: 4.0

I would like to use the *exe.config file, which is generated in the Packaging process, to store configuration information used by my PowerShell script/application. But I could not find any information, if this is possible or how to achive this. I am aware about the possibilities to store/load Variables with Export-CliXml, but I would like to achieve this via PowerShell Studio features.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Storing configuration in *exe.config file

Post by davidc »

PowerShell Studio doesn't offer any options to configure the application .config file other than what is automatically generated.

You can, after generating the config file for the first time, disable the option the generated the config file. This way any changes you make to the config file will not get overwritten by the packager.
Packager Generate .config file.png
Packager Generate .config file.png (31.06 KiB) Viewed 2332 times
As for access the config settings, you can look at using the ConfigurationManager class:

https://msdn.microsoft.com/en-us/librar ... nager.aspx
  1. Add-Type -AssemblyName System.Configuration
  2. [System.Configuration.ConfigurationManager]
I recommend posting on the PowerShell forum for further assistance on how to read the settings.
David
SAPIEN Technologies, Inc.
This topic is 7 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.