---
title: "Get-DbaDefaultPath"
description: "Retrieves default file paths for SQL Server data, log, backup, and error log directories"
url: "https://dbatools.io/Get-DbaDefaultPath/"
availability: "Windows, Linux, macOS"
tags: ["Storage", "Data", "Log", "Backup"]
author: "Chrissy LeMaire (@cl), netnerds.net"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaDefaultPath.ps1"
last_updated: "2024-01-01"
---

# Get-DbaDefaultPath

## Synopsis

Retrieves default file paths for SQL Server data, log, backup, and error log directories

## Description

Retrieves the default directory paths that SQL Server uses for new database files, transaction logs, backups, and error logs. This information is essential for capacity planning, automated database provisioning, and understanding where SQL Server will place files when no explicit path is specified. The function uses multiple fallback methods to determine these paths, including server properties, system queries, and examining existing system databases when standard properties are unavailable.

## Syntax

```powershell
Get-DbaDefaultPath
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Returns the default file paths for sql01\sharepoint

```powershell
PS C:\> Get-DbaDefaultPath -SqlInstance sql01\sharepoint
```

### Example 2: Returns the default file paths for &quot;sql2014&quot;,&quot;sql2016&quot; and &quot;sqlcluster\sharepoint&quot;

```powershell
PS C:\> $servers = "sql2014","sql2016", "sqlcluster\sharepoint"
PS C:\> $servers | Get-DbaDefaultPath
```

### Required Parameters

##### -SqlInstance

The target SQL Server instance or instances. Accepts named instances (server\instance) and pipeline input for batch processing.  
Use this to query multiple SQL Server instances at once to compare their default path configurations across your environment.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | True |
| Pipeline | true (ByValue) |
| Default Value |  |

### Optional Parameters

##### -SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).  
Use this when Windows Authentication isn't available or when you need to connect using SQL Server Authentication or service accounts.  
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.  
For MFA support, please use Connect-DbaInstance.

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

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

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

## Outputs

**PSCustomObject**

Returns one object per SQL Server instance with the default file paths configured for that server.

**Properties:**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name (ServiceName)
- SqlInstance: The full SQL Server instance name in computer\instance format (DomainInstanceName)
- Data: The default directory path for new database data files
- Log: The default directory path for new transaction log files
- Backup: The default directory path for database backups
- ErrorLog: The directory path where SQL Server stores error log files

---

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