Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Ensure AppSetting

Ensures a .NET application configuration file has the specified appSetting key/value pair.

Script usage:

DotNet::Ensure-AppSetting(
	File: <text>,
	Key: <text>,
	Value: <text>,
	[AppSettingsXPath: <text>]
);

Arguments:

NameFormatScript UsageUsage Notes
Config file path
text
File
The file path of the configuration file, typically web.config or app.config. This argument is required.
AppSetting key
text
Key
This argument is required.
AppSetting value
text
Value
This argument is required.
XPath for appSettings
text
AppSettingsXPath
Value note: "default".

Note: By default, the "appSettings" section must exist in the file under the "configuration" element in order to ensure the key/value pair is present. Use the AppSettingsXPath argument to select a different element instead.

Example:

# ensures that the application is configured to use test mode for the example third-party API
DotNet::Ensure-AppSetting(
	File: E:\Website\web.config,
	Key: Accounts.ThirdParty.PaymentApi,
	Value: https://test.example.com/api/v3
);