Last active
June 21, 2016 06:07
-
-
Save timyhac/1093198648aaf565d8e0e5a3e74bba77 to your computer and use it in GitHub Desktop.
Get SQL Server Backup Folder powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module sqlps | |
Function GetMSSQLBackupFolder | |
{ | |
param([string]$ServerInstance) | |
# taken from https://www.mssqltips.com/sqlservertip/1966/function-to-return-default-sql-server-backup-folder/ | |
$GetBackupFolder = "EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer',N'BackupDirectory'" | |
return (Invoke-sqlcmd -ServerInstance $ServerInstance -Query $GetBackupFolder).Data | |
} | |
GetMSSQLBackupFolder -ServerInstance "localhost\SQLEXPRESS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment