protected override void ProcessRecord() { base.ProcessRecord(); try { var userService = new UserService(ServiceUrl, MessageHandler, ProgressHandler); userService.Initialize(UserName, Password); } catch (AggregateException ae) { this.WriteErrorsAndThrowOnLast( ae.Flatten().InnerExceptions.Select(LazyCreateError)); } catch (Exception e) { ThrowTerminatingError(LazyCreateError(e)); } }