Created
January 4, 2015 16:16
-
-
Save martin9700/f28713757122bf1cf994 to your computer and use it in GitHub Desktop.
This file contains 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
If ($Result) | |
{ | |
$BackupByDBQuery = @" | |
WITH fs | |
AS | |
( | |
SELECT database_id, type, size * 8.0 / 1024 AS size | |
FROM sys.master_files | |
) | |
SELECT | |
db.name, | |
db.database_id, | |
CAST(ROUND((SELECT SUM(size) FROM fs WHERE type = 0 AND fs.database_id = db.database_id),2) AS DECIMAL(12,2)) AS FileSizeMB, | |
CAST(ROUND((SELECT SUM(size) FROM fs WHERE type = 1 AND fs.database_id = db.database_id),2) AS DECIMAL(12,2)) AS LogSizeMB | |
FROM sys.databases as db | |
WHERE name = '$($Select.Name)' | |
"@ | |
$NewSizes = Invoke-SQLQuery -Instance $Instance -Database Master -MultiSubnetFailover -Query $BackupByDBQuery | |
$Select | Add-Member -MemberType NoteProperty -Name NewFileSizeMB -Value ($NewSizes.FileSizeMB) | |
$Select | Add-Member -MemberType NoteProperty -Name NewLogSizeMB -Value ($NewSizes.LogSizeMB) | |
Write-Output $Select |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment