Skip to content

Commit

Permalink
Update Set-DbaTempDbConfig.ps1 (dataplat#6898)
Browse files Browse the repository at this point in the history
  • Loading branch information
devondba authored Oct 7, 2020
1 parent 875a24a commit 66d03ed
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions functions/Set-DbaTempDbConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,21 @@ function Set-DbaTempDbConfig {

$logfile = Get-DbaDbFile -SqlInstance $server -Database tempdb | Where-Object Type -eq 1 | Select-Object LogicalName, PhysicalName, @{L = "SizeMb"; E = { $_.Size.Megabyte } }

if ($LogFileSize) {
if ($LogPath -or $LogFileSize) {
$Filename = Split-Path $logfile.PhysicalName -Leaf
$LogicalName = $logfile.LogicalName
$NewPath = "$LogPath\$Filename"

if ($LogPath) {
$NewPath = "$LogPath\$Filename"
} else {
$NewPath = $logfile.PhysicalName
}

if (-not($LogFileSize)) {
$LogFileSize = $logfile.SizeMb
}

$sql += "ALTER DATABASE tempdb MODIFY FILE(name=$LogicalName,filename='$NewPath',size=$LogFileSize MB,filegrowth=$LogFileGrowth);"
} else {
$LogFileSize = $logfile.SizeMb
}

Write-Message -Message "SQL Statement to resize tempdb." -Level Verbose
Expand Down

0 comments on commit 66d03ed

Please sign in to comment.