---
title: "Set-DbatoolsInsecureConnection"
description: "Reverts SQL Server connection security defaults to disable encryption and trust all certificates"
url: "https://dbatools.io/Set-DbatoolsInsecureConnection/"
availability: "Windows, Linux, macOS"
source: "https://github.com/dataplat/dbatools/blob/master/public/Set-DbatoolsInsecureConnection.ps1"
last_updated: "2024-01-01"
---

# Set-DbatoolsInsecureConnection

## Synopsis

Reverts SQL Server connection security defaults to disable encryption and trust all certificates

## Description

Microsoft changed the default connection settings in SQL Server client libraries to require encryption and validate certificates, which can break existing dbatools scripts and connections in development environments. This function reverts those security defaults by configuring dbatools to trust all server certificates and disable encryption requirements.  
  
The function sets two key dbatools configuration values: sql.connection.trustcert (true) and sql.connection.encrypt (false). By default, these settings persist across PowerShell sessions, but you can use -SessionOnly to apply them temporarily.  
  
This is particularly useful when working with development servers, self-signed certificates, or legacy environments where the new security defaults cause connection failures.  
  
You can read more here: https://dbatools.io/newdefaults

## Syntax

```powershell
Set-DbatoolsInsecureConnection
    [-SessionOnly]
    [[-Scope] {UserDefault | UserMandatory | SystemDefault | SystemMandatory | FileUserLocal | FileUserShared | FileSystem}]
    [-Register]
    [<CommonParameters>]

```

## Examples

### Example 1: Sets the default connection settings to trust all server certificates and not require encrypted connections

```powershell
PS C:\> Set-DbatoolsInsecureConnection
```

### Example 2: Sets the default connection settings to trust all server certificates and not require encrypted connections

```powershell
PS C:\> Set-DbatoolsInsecureConnection -SessionOnly
```

Sets the default connection settings to trust all server certificates and not require encrypted connections.  
Does not persist across sessions so the default will return if you close and reopen PowerShell.  

### Optional Parameters

##### -SessionOnly

Applies the insecure connection settings only to the current PowerShell session instead of persisting them permanently.  
Use this when testing connection settings or when you need insecure connections temporarily without changing your permanent dbatools configuration.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -Scope

Specifies where to store the persistent connection settings when SessionOnly is not used. Defaults to UserDefault.  
UserDefault applies to the current user only, while SystemDefault applies to all users on the machine.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | UserDefault |

##### -Register

This parameter is deprecated and will be removed in a future release.  
The function now automatically handles registration of settings when SessionOnly is not specified.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**None**

This command configures dbatools connection security settings but does not output any objects to the pipeline. The internal configuration values are applied silently to enable insecure connections (disabled encryption, trusted certificates).

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
