Object already exists when trying to use aspnet_regiis to encrypt web.config connectionStrings section

Issue:

When I tried to encrypt my web.config connectionStrings section with aspnet_regiis, I got an error message saying Object already exists. What happen?

Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Encrypting configuration section...
An error occurred executing the configuration section handler for connectionStrings.


Failed to encrypt the section 'connectionStrings' using provider 'MyIisRsaProv'. Error message from the provider: Object already exists.


Failed!

Environment:

Windows 10, .Net Framework v4.0.30319, PowerShell ISE or Command Prompt

Resolution:

In order to run aspnet_regiis to encrypt configuration section(s), you need to run PowerShell ISE or Command Prompt with Run as administrator

Step-by-step instructions:-

  1. Click on search on your Windows 10 machine and type powershell or command prompt

  2. Right click on Windows PowerShell ISE and select “Run as administrator”
  3. Enter your encryption command and run, ex., C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings c:\temp\ -prov MyIisRsaProv
  4. You should get succeed result as below:

    Microsoft (R) ASP.NET RegIIS version 4.0.30319.0

    Administration utility to install and uninstall ASP.NET on the local machine.

    Copyright (C) Microsoft Corporation. All rights reserved.

    Encrypting configuration section...

    Succeeded!

Troubleshoot:

If you still having problem, make sure you run PowerShell or Command Prompt as Administrator by checking Window Title:
 

Reference:

Sample PowerShell to encrypt existing configuration sections:

        $app_path = "c:\your\Web.Config\folder"
        Write-Host "> connectionStrings"
        $bol_encrypt_config_here = 0
        Get-Content $app_path\web.config | ForEach-Object {if($_ -match "connectionStrings"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings $app_path -prov MyIisRsaProv }
       
        Write-Host "> machineKey"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "machineKey"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef system.web/machineKey $app_path -prov MyIisRsaProv }
       
        Write-Host "> sessionState"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "sessionState"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef system.web/sessionState $app_path -prov MyIisRsaProv }
       
        Write-Host "> appSettings"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "appSettings"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef appSettings $app_path -prov MyIisRsaProv }

Windows 10 Can’t Connect to File Share with SMB1

Issue:

When I tried to copy files from my Windows 10 local drive to Windows 2008 R2 Server file share, I get a strange error:

You can't connect to the file share because it's not secure. This share requires the obsolete SMB1 protocol, which is unsafe and could expose your system to attack.
Your system requires SMB2 or higher. For more info on resolving this issue, see: https://go.microsoft.com/fwlink/?linkid=852747

It’s telling me the target file server is running an obsolete SMB1 protocol and I can’t connect to it from Windows 10. Windows 10 is running SMB2 and I can’t install SMB2 to Windows Server. What can I do?

Environment:

Windows 10, File Explorer, Windows 2008 R2 Server File Share

Resolution:

Since you can’t install SMB2 on Windows Server, what you can do is enable SMB1 on your Windows 10 machine. You can either enable SMB1 by GUI (Graphic User interface) or PowerShell script.

Step-by-step instructions:-

Enable SMB1 by GUI:

  1. Open Windows Features by searching for windows feature
  2. Click on “Turn Windows features on or off” and scroll down to “SMB 1.0/CIFS File Sharing Support”
  3. Click on check box next to “SMB 1.0/CIFS File Sharing Support”
  4. Click on “OK” button to apply the changes
  5. Follow the instructions to restart your machine for changes to take effect.
  6. Once restart, try to copy the file again.

 

Enable SMB1 by PowerShell (Run as administrator required):

  1. Open PowerShell window by searching for powershell on your Windows 10 machine
  2. Right click on “Windows PowerShell” and select “Run as administrator”
  3. Enable SMB1 by entering: Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
    PS C:\windows\system32> Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
    
    Do you want to restart the computer to complete this operation now?
    
    [Y] Yes  [N] No  [?] Help (default is "Y"):

  4. Hit “Enter” key or type “y” to restart for changes to take effect
  5. Once restart, try to copy the file again.

 

Troubleshoot:

Enter this PowerShell (run as administrator) to check if SMB1 protocol enable on your machine:

PS C:\> Get-SmbServerConfiguration | Select EnableSMB1Protocol

EnableSMB1Protocol
------------------
             False

 

Reference:

How to detect, enable and disable SMBv1, SMBv2, and SMBv3 in Windows and Windows Server