Patricio Treviño

Patricio Treviño

Husband . Father . Developer

Decrypt a configuration section in a configuration file hosted in IIS

Syntax

aspnet_regiis -pd <section> -app <virtualPath> [-location <subPath>] [-pkm]
view raw syntax.text hosted with ❤ by GitHub

Option Description
section The section of the web.config to be encrypted.
virtualPath The IIS website that hosts the web.config.
location The subpath inside the IIS website that hosts the web.config.
pkm Encrypts the machine config instead of the local config.

Example

# Given a configuration fle like
# <configuration>
# <configProtectedData>
# <providers>
# <add name="MyProtectedConfigurationProvider"
# type="System.Configuration.RsaProtectedConfigurationProvider, ..."
# keyContainerName="MyKeyContainer"
# useMachineContainer="true" />
# </providers>
# </configProtectedData>
# </configuration>
$ cd "$env.WINDIR/Microsoft.NET/Framework64/v4.0.30319"
$ .\aspnet_regiis -pd connectionStrings -app "/Default Website"
Microsoft (R) ASP.NET RegIIS version 4.0.30319.18408
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Decrypting configuration sections...
Succeeded!
view raw example.ps1 hosted with ❤ by GitHub

References

How to: Decrypt a web.config