Execution Flow
The schedule runs the sync script daily at 02:00 via the SQL Agent CmdExec subsystem, executing the standalone
Sync-Job.ps1 packaged with the module — not a PowerShell subsystem step. Use -Force to recreate an existing job.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -JobName | String | Optional | Name of the Agent job. Default: sqmAutoLoginSync. |
| -Force | Switch | Optional | Overwrites an existing job with the same name. |
| -WhatIf | Switch | Optional | Preview actions without creating the job. |
| -Confirm | Switch | Optional | Prompt before creating the job. |
Return Value
Returns a PSCustomObject with: SqlInstance, JobName, Status (Success), Message, Timestamp.
Examples
Example 1 — Create job with default schedule
New-sqmAutoLoginSyncJob -SqlInstance "SQL01"
Example 2 — Replace existing job
New-sqmAutoLoginSyncJob -SqlInstance "SQL01" -Force