protected override void ProcessRecord() { var details = new MonitoringNewInstance { InstallPath = InstallPath, LogPath = LogPath, Name = Name, DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName, ServiceDescription = Description, ServiceAccount = ServiceAccount, ServiceAccountPwd = ServiceAccountPassword, HostName = HostName, Port = Port, ErrorQueue = ErrorQueue, ConnectionString = ConnectionString, TransportPackage = MonitoringTransports.All.First(t => t.Matches(Transport)), SkipQueueCreation = SkipQueueCreation }; var zipfolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path); var logger = new PSLogger(Host); var installer = new UnattendMonitoringInstaller(logger, zipfolder); try { logger.Info("Installing Monitoring instance..."); if (installer.Add(details, PromptToProceed)) { var instance = InstanceFinder.FindMonitoringInstance(details.Name); if (instance != null) { WriteObject(PsMonitoringService.FromInstance(instance)); } else { throw new Exception("Unknown error creating instance"); } } } catch (Exception ex) { ThrowTerminatingError(new ErrorRecord(ex, null, ErrorCategory.NotSpecified, null)); } }