protected override void ProcessRecord() { var logger = new PSLogger(Host); var zipfolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path); var installer = new UnattendMonitoringInstaller(logger, zipfolder); foreach (var name in Name) { var instance = InstanceFinder.FindMonitoringInstance(name); if (instance == null) { WriteWarning($"No action taken. An instance called {name} was not found"); break; } WriteObject(installer.Delete(instance.Name, RemoveLogs.ToBool())); } }
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)); } }
protected override void ProcessRecord() { var logger = new PSLogger(Host); var zipFolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path); var installer = new UnattendMonitoringInstaller(logger, zipFolder); foreach (var name in Name) { var instance = InstanceFinder.FindMonitoringInstance(name); if (instance == null) { WriteWarning($"No action taken. An instance called {name} was not found"); break; } if (!installer.Upgrade(instance)) { ThrowTerminatingError(new ErrorRecord(new Exception($"Upgrade of {instance.Name} failed"), "UpgradeFailure", ErrorCategory.InvalidResult, null)); } } }