Skip to content

Instantly share code, notes, and snippets.

@jhorsman
Created October 3, 2018 19:46
Show Gist options
  • Select an option

  • Save jhorsman/45ffd2e4b9f58f261e619666111985bd to your computer and use it in GitHub Desktop.

Select an option

Save jhorsman/45ffd2e4b9f58f261e619666111985bd to your computer and use it in GitHub Desktop.
Encrypt web.cofig sections with PowerShell
# 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