· Uwe Janke
Commands / Get-sqmFileGrowthHistory

Get-sqmFileGrowthHistory

Diagnostics & HealthsqmSQLTool v1.8.2+ · GetTXT/CSV/HTML Export  ✅ -WhatIf supported
Uses Get-sqmAutoGrowthReport as the data source for the current size and AutoGrowth configuration of every data/log file, then appends each run's sizes to a per-instance JSON snapshot history (same approach as Get-sqmDiskSpaceReport). A linear least-squares regression over the last -HistoryDays days yields MB/day growth per file and, for files with a bounded MaxSize, an estimated number of days until MaxSize is reached. At least -MinDataPoints runs are needed before a forecast is produced - until then a file is reported as "collecting" rather than a silent n/a. Needs a recurring schedule (e.g. a daily Agent job) to accumulate snapshots; a single run establishes the baseline only.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestring[]Optional$env:COMPUTERNAMEOne or more instances. Pipeline-capable.
-SqlCredentialPSCredentialOptional, Credentials for the connection.
-Databasestring[]Optional, Restrict to specific databases.
-IncludeSystemswitchSwitch$falseInclude system databases.
-HistoryDaysintOptional30Look-back window (in days) of the snapshot history used for the regression.
-OutputPathstringOptionalGet-sqmDefaultOutputPath\FileGrowthReportsOutput directory for the TXT/CSV/HTML report files.
-HistoryPathstringOptional<OutputPath>\HistoryDirectory holding the per-instance snapshot history (FileGrowthHistory_<Instance>.json).
-MinDataPointsintOptional5Minimum number of snapshots within the window before a forecast is produced.
-NoHistoryswitchSwitch$falseDo not append the current run to the history (forecast still uses whatever history already exists).
-ContinueOnErrorswitchSwitch$falseContinue on error for an instance (otherwise the error is thrown).
-EnableExceptionswitchSwitch$falseThrow exceptions immediately - overrides -ContinueOnError.
-NoOpenswitchSwitch$falseDo not automatically open the generated HTML report.
-WhatIf / -ConfirmswitchOptional, Shows which files would be created without writing them - the history snapshot is not persisted under -WhatIf either.

Execution Flow

START dbatools installed? NO throw: dbatools not found YES foreach $instance in $SqlInstance Get-sqmAutoGrowthReport -Detailed -NoReport Current size + AutoGrowth config of every data/log file, right now Load FileGrowthHistory_<Instance>.json (if present) Prior snapshots: Timestamp, DatabaseName, FileName, SizeMB Merge history + current snapshot, trim to -HistoryDays window window = now .. now - HistoryDays -NoHistory or -WhatIf? NO YES Persist current snapshot to history (retain 400 days) Atomic write: .tmp file then Move-Item Per file: Get-sqmVolumeForecast (linear regression) < -MinDataPoints in window -> Basis ≠ 'History', status "collecting" bounded file + DaysUntilFull ≤ 30 -> Warning Write TXT + CSV + HTML report to -OutputPath Invoke-sqmOpenReport (unless -NoOpen) Add instance result to $allInstanceResults, continue loop Return [PSCustomObject[]]: DetailRows, TxtFile, CsvFile, HtmlFile, Status DONE

Examples

Run once to establish the baseline (forecast fills in after a few runs)
Get-sqmFileGrowthHistory -SqlInstance "SQL01"
Shorter regression window, custom report location
Get-sqmFileGrowthHistory -SqlInstance "SQL01" -HistoryDays 14 -OutputPath "D:\Reports"
Scheduled daily run (SQL Agent job step) - typical way to build up history
Get-sqmFileGrowthHistory -SqlInstance "SQL01" -NoOpen -ContinueOnError