Get-SqlDefaultDir
Returns the default location for data and log files for a SQL Server.
Syntax
Get-SqlDefaultDir [-sqlserver] <Object> [-dirtype] <String> [<CommonParameters>]
Detailed Description
The Get-SqlDefaultDir function returns the default location for data and log files for the specified SQL Server.
Related Commands
Parameters
Name |
Description |
Required? |
Pipeline Input |
Default Value |
sqlserver |
|
true |
false |
|
dirtype |
|
true |
false |
|
Input Type
None
You cannot pipe objects to Get-SqlDefaultDir
Return Values
System.String
Get-SqlDefaultDir returns a System.Stringt.
Notes
The DefaultFile and DefaultLog properties are only written to registry if you modify the properties in SSMS
even setting the properties to same value will create the registry keys. If the properties have not been created
Get-SqlDefaultDir will use the InstallDataDirectory properties. This seems to recreate how SSMS works.
Examples
EXAMPLE 1
Get-SqlDefaultDir "Z002\sql2k8" "Data"
This command returns the default data directory for the Z002\sql2k8 server.
EXAMPLE 2
Get-SqlDefaultDir "Z002\sql2k8" "Log"
This command returns the default log directory for the Z002\sql2k8 server.