public void DeleteInstance() { var installer = new UnattendServiceControlInstaller(new TestLogger(), DeploymentCache); foreach (var instance in InstanceFinder.ServiceControlInstances().Where(p => p.Name.StartsWith("Test.ServiceControl", StringComparison.OrdinalIgnoreCase))) { installer.Delete(instance.Name, true, true); } }
protected override void ProcessRecord() { var logger = new PSLogger(Host); var zipfolder = Path.GetDirectoryName(MyInvocation.MyCommand.Module.Path); var installer = new UnattendServiceControlInstaller(logger, zipfolder); foreach (var name in Name) { var instance = InstanceFinder.FindServiceControlInstance(name); if (instance == null) { WriteWarning($"No action taken. An instance called {name} was not found"); break; } WriteObject(installer.Delete(instance.Name, RemoveDB.ToBool(), RemoveLogs.ToBool())); } }
public static ActionResult ServiceControlUnattendedRemoval(Session session) { var logger = new MSILogger(session); var removeInstancesPropertyValue = session["REMOVEALLINSTANCESANDDATA"]; if (string.IsNullOrWhiteSpace(removeInstancesPropertyValue)) { return(ActionResult.NotExecuted); } switch (removeInstancesPropertyValue.ToUpper()) { case "YES": case "TRUE": break; default: return(ActionResult.NotExecuted); } if (InstanceFinder.ServiceControlInstances().Count == 0) { return(ActionResult.Success); } var unattendedInstaller = new UnattendServiceControlInstaller(logger, session["APPDIR"]); foreach (var instance in InstanceFinder.ServiceControlInstances()) { try { unattendedInstaller.Delete(instance.Name, true, true); } catch (Exception ex) { logger.Error($"Error thrown when removing instance {instance.Name} - {ex}"); } } return(ActionResult.Success); }