Execution Flow
On a secondary the job step ends with success without doing anything, so after a failover the new primary takes over. Jobs created by older versions (step calls
jobs\Sync-Job.ps1) keep running; recreate them with -Force to switch over.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -AvailabilityGroupName | String | Optional | AG to sync. Default: the first AG on the instance. |
| -JobName | String | Optional | Name of the Agent job. Default: sqmAutoLoginSync. |
| -AuditAdOrphans | Switch | Optional | After each run, report Windows logins without an AD account (event 9003). Detection only, nothing is deleted. |
| -BackupRetentionDays | Int | Optional | Retention for login backups and audit reports in days. Sync default: 7, 0 keeps all. |
| -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 the result of Install-sqmStandardJob: Name, SqlInstance, JobName, FunctionName, Parameters, ScheduleName, PrimaryOnly, Started, Status, Message, Timestamp.
Examples
Example 1, Create job with default schedule
New-sqmAutoLoginSyncJob -SqlInstance "SQL01"Example 2, Replace an old job, with AD orphan report
New-sqmAutoLoginSyncJob -SqlInstance "SQL01" -AvailabilityGroupName "ProdAG" -AuditAdOrphans -Force