Skip to content

Instantly share code, notes, and snippets.

@jmelosegui
Created September 26, 2020 17:01
Show Gist options
  • Save jmelosegui/74f2889f6611db15e5010fbe25226972 to your computer and use it in GitHub Desktop.
Save jmelosegui/74f2889f6611db15e5010fbe25226972 to your computer and use it in GitHub Desktop.
Add-Type -AssemblyName System.Configuration
$fileMap = New-Object -TypeName System.Configuration.ExeConfigurationFileMap
$fileMap.ExeConfigFilename = "app.config"
$configurationUserLevelNone = 0
$config = [System.Configuration.ConfigurationManager]::OpenMappedExeConfiguration($fileMap, $configurationUserLevelNone)
$section = $config.GetSection("connectionStrings");
if ($section.SectionInformation.IsProtected -eq $false)
{
$section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider")
$config.Save(0)
}
Add-Type -AssemblyName System.Configuration
$fileMap = New-Object -TypeName System.Configuration.ExeConfigurationFileMap
$fileMap.ExeConfigFilename = "app.config"
$configurationUserLevelNone = 0
$config = [System.Configuration.ConfigurationManager]::OpenMappedExeConfiguration($fileMap, $configurationUserLevelNone)
$section = $config.GetSection("connectionStrings");
if ($section.SectionInformation.IsProtected -eq $true)
{
$section.SectionInformation.UnProtectSection()
$config.Save(0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment