dbatools
dbatools copied to clipboard
Sync-DbaAvailabilityGroup: You cannot call a method on a null-valued expression
Verified issue does not already exist?
Yes
What error did you receive?
If i execute Sync-DbaAvailabilityGroup, it runs through all the checks, but then fails at the end with "Sync-DbaAvailabilityGroup: You cannot call a method on a null-valued expression"
Ive tested with both specifying the credential set, and using Windows Integrated login.
PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.PSScriptCmdlet.RunClause(Action
1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.CommandProcessorBase.Complete()
TargetObject :
CategoryInfo : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Sync-DbaAvailabilityGroup<End>, C:\Users\krle\Documents\PowerShell\Modules\dbatools\1.1.90\allcommands.ps1: line 124698
at <ScriptBlock>, <No file>: line 3
PipelineIterationInfo : {}
Steps to Reproduce
$SQLAvailabilityGroupName = "RedactedAvailabilityGroupName"
$SQLCredential = Get-credential
$PrimaryNode = "RedactedPrimaryNodeName"
$SecondaryNode = "RedactedSecondaryNodeName"
Sync-DbaAvailabilityGroup -Primary $PrimaryNode -Secondary $SecondaryNode `
-AvailabilityGroup $SQLAvailabilityGroupName `
-PrimarySqlCredential $SQLCredential `
-SecondarySqlCredential $SQLCredential `
-WarningAction SilentlyContinue `
-ErrorAction stop
Are you running the latest release?
Yes
Other details or mentions
No response
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe)
PowerShell Host Version
PSVersion 7.2.3 PSEdition Core GitCommitId 7.2.3 OS Microsoft Windows 10.0.22000 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 2017 (RTM-CU22-GDR) (KB4583457) - 14.0.3370.1 (X64) Nov 6 2020 18:19:52 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor)
.NET Framework Version
.NET 6.0.4