Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
PS C:\Windows\system32> $error[0] | select *
PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Sync-DbaAvailabilityGroup, : line 81379
at , : line 1
PipelineIterationInfo : {}
Steps to Reproduce
Sync-DbaAvailabilityGroup -Primary rxx1 -AvailabilityGroup axxcgrp
Please confirm that you are running the most recent version of dbatools
2.1.31
Other details or mentions
If there are no Agent Operators or even if there is an Agent operator, but the operator has no days scheduled, and then also Agent Proxy if there is no proxy. If excluding those no errors.
I created a proxy user, and I created an Operator but didn't assign any days.
Proxy worked, Operator gave the error still. I added a day to Operator and ran again, and no more errors.
If there is no operator or proxy, if I run copy-dbaagentoperator or if I run copy dbaagentproxy on their own with -source and -destination it just outputs nothing, which is where sync-DbaAvailabilityGroup gets a NULL value result (I assume) and gives an error, and happens exactly the same if -EnableException is used or not. Same exact info.
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe), Windows PowerShell ISE (powershell_ise.exe), PowerShell Core (pwsh.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.14393.7783
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.7783
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Value
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SQL Server Edition and Build number
Microsoft SQL Server 2019 (RTM-CU32) (KB5054833) - 15.0.4430.1 (X64)
Feb 21 2025 17:28:26
Copyright (C) 2019 Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
and
Microsoft SQL Server 2022 (RTM-CU18) (KB5050771) - 16.0.4185.3 (X64)
Feb 28 2025 18:24:49
Copyright (C) 2022 Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)
Microsoft SQL Server 2022 (RTM-CU18) (KB5050771) - 16.0.4185.3 (X64)
Feb 28 2025 18:24:49
Copyright (C) 2022 Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2025 Standard 10.0 (Build 26100: )
.NET Framework Version
.NET Framework 4.8.4775.0