Posted On June 15, 2020

PowerShell: Obtaining SQL Database Default Paths

kimconnect 0 comments
blog.KimConnect.com >> Codes , Database >> PowerShell: Obtaining SQL Database Default Paths
# This function returns an array of 3 string values reflecting default Data, Log, and Backup directories as set on a certain SQL server
function getDefaultSqlPaths($sqlServer=$env:computername){
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
    $sqlConnection = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $sqlServer 
    $defaultBackupDirectory=$sqlConnection.Settings.BackupDirectory
    $defaultDataDirectory=$sqlConnection.Settings.DefaultFile
    $defaultLogDirectory=$sqlConnection.Settings.DefaultLog
    return @($defaultDataDirectory,$defaultLogDirectory,$defaultBackupDirectory)
    }
getDefaultSqlPaths

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Check Registry Path, Key, and Dword Value

$path='HKLM:\Software\Intel' $keyName='GMM' $dwordName='DedicatedSegmentSize' $dwordValue=512 Function CheckRegistryKey { param( [Parameter(Position = 0, Mandatory = $true)][String]$path, [Parameter(Position…

Some Useful Windows Commands to Troubleshoot Networking on Windoze

# Check this computer's trust relationship to its domain controllers$domainName="intranet.kimconnect.com"PS C:\Windows\system32> nltest /SC_QUERY:$domainNameFlags: 0Trusted DC…

JavaScript: Use the TwitchTV JSON API

Demo: https:// codepen.io/dragoncoin/pen/Zebwvq HTML Code: <div class="container"> <div class="row" id="header"> <h1>Selected Twitch Streamers</h1> <div class="menu">…
Other project: DragonCoin.com