Created
October 3, 2018 19:46
-
-
Save jhorsman/45ffd2e4b9f58f261e619666111985bd to your computer and use it in GitHub Desktop.
Encrypt web.cofig sections with PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # from https://joshjoubert.wordpress.com/2013/03/28/encrypting-and-decrypting-sections-of-a-web-config-with-powershell/ | |
| # example: Encrypt-ConfigurationSection 1 ‘/WebApplication1’ ‘connectionStrings’ ‘v4.0.30319’ | |
| function Encrypt-ConfigurationSection([int] $id, [string] $app, [string] $section, [string] $version){ | |
| $currentDirectory = (Get-Location) | |
| Set-Location "C:\windows\Microsoft.Net\Framework\$version\" | |
| .\aspnet_regiis.exe -pe $section -app $app -site $id -prov "RsaProtectedConfigurationProvider" | |
| Set-Location $currentDirectory | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment