Execution Flow
FITS defaults:
-Full Sunday 20:00, -Diff Mon–Sat 20:00, -Log every day, every 15 minutes. When -UseExcludeTable is combined with auto-detection, an existing FULL/LOG job's schedule (if present) is reused, otherwise the default 21:15 daily FULL / 15-min LOG cadence is applied and the DIFF job is auto-disabled. Secondary-replica propagation reuses this same function recursively, tagging results Secondary_<status>.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -Full / -Diff / -Log | Switch | At least one required | Which backup type job(s) to create. |
| -BackupDirectory | String | Optional | Backup root path; target is <path>\Usr-db. |
| -UseExcludeTable | Switch | Optional | Reads sqm_BackupExclude at job runtime via dynamic SQL, and triggers schedule auto-detection from existing jobs. |
| -JobCategory | String | Optional | Default: Database Maintenance. |
| -EnableException | Switch | Optional | Throws terminating errors instead of returning an error status object. |
| -SkipAlwaysOnPropagation | Switch | Optional | Skips recursive job creation on AG secondary replicas. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support. |
Return Value
Returns an array of PSCustomObject, one per created backup type, each with: SqlInstance, BackupType, JobName, BackupDirectory, Databases, ScheduleTime, ScheduleDays, JobStatus, OverallStatus, Message.
Examples
Example 1 — Create FULL + LOG jobs with exclude table
New-sqmOlaUsrDbBackupJob -SqlInstance "SQL01" -Full -Log -UseExcludeTable
Example 2 — All three types, explicit backup path
New-sqmOlaUsrDbBackupJob -SqlInstance "SQL01" -Full -Diff -Log -BackupDirectory "E:\Backup"