Execution Flow
Object types:
Logins, Jobs, LinkedServers, Operators, Alerts. Use -ExcludeType to skip categories. -IncludeSystemObjects also syncs system logins (sa, ##MS_*##). -ContinueOnError lets the sync continue when individual objects fail. Errors are always written via Invoke-sqmLogging.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Primary replica instance. Default: $env:COMPUTERNAME. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -AvailabilityGroup | String | Optional | Target AG name. If omitted, all AGs on the instance are processed. |
| -ExcludeType | String[] | Optional | Object types to skip. Values: Logins, Jobs, LinkedServers, Operators, Alerts. |
| -ObjectName | String | Optional | Wildcard filter — only sync objects matching this name pattern. |
| -IncludeSystemObjects | Switch | Optional | Also sync system logins and system SQL Agent jobs. |
| -ContinueOnError | Switch | Optional | Log errors as warnings and continue instead of aborting. |
| -EnableException | Switch | Optional | Re-throw errors as terminating exceptions. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support. |
Return Value
Returns a PSCustomObject[] — one entry per synced object — with: Secondary, ObjectType, ObjectName, Status, Message.
Examples
Example 1 — Sync all object types to all AG secondaries
Sync-sqmAgNode -SqlInstance "SQL01" -AvailabilityGroup "AG_PROD"
Example 2 — Sync only Logins and Jobs, continue on error
Sync-sqmAgNode -SqlInstance "SQL01" -ExcludeType 'LinkedServers','Operators','Alerts' -ContinueOnError
Example 3 — Sync a single login by name
Sync-sqmAgNode -SqlInstance "SQL01" -ExcludeType 'Jobs','LinkedServers','Operators','Alerts' -ObjectName "DOMAIN\AppUser"