[99.96 ms] C:\github\dbatools> Get-DbaAgReplica -SqlInstance sql2016a -Replica sql2016c | Remove-DbaAgReplica
Confirm
Are you sure you want to perform this action?
Performing the operation "Removing availability group replica [SQL2016C]" on target "sql2016a".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
WARNING: [17:47:47][Remove-DbaAgReplica] Failure | Cannot index into a null array.
[1.77 s] C:\github\dbatools> $error[0] | select *
writeErrorStream : True
PSMessageDetails :
Exception : System.Exception: Cannot index into a null array. ---> System.Management.Automation.RuntimeException: Cannot index into a null array.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
--- End of inner exception stack trace ---
TargetObject :
CategoryInfo : InvalidOperation: (:) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Remove-DbaAgReplica,Stop-Function
ErrorDetails : Cannot index into a null array.
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Stop-Function, <No file>: line 231
at Remove-DbaAgReplica<Process>, <No file>: line 91
at Select-DefaultView<Process>, <No file>: line 68
at Get-DbaAgReplica<Process>, <No file>: line 86
at <ScriptBlock>, <No file>: line 1