/// <summary> /// Implements the <see cref="ProcessRecord"/> method for <see cref="CloseTransmissionSessionCmdlet"/>. /// </summary> protected override void ProcessRecord() { try { var sessionSvc = new SessionService(); bool success = Task.Run(async() => await sessionSvc.Close()).Result; if (success) { WriteObject("Session closed"); } else { ThrowTerminatingError(new ErrorRecord(new Exception("Failed to close session"), null, ErrorCategory.OperationStopped, null)); } } catch (Exception e) { ThrowTerminatingError(new ErrorRecord(new Exception($"Failed to close session with error: {e.Message}", e), null, ErrorCategory.OperationStopped, null)); } }