protected override void ProcessRecord() { var TeamNameList = TeamName?.ToList().ConvertAll(s => s.ToLower()); var baseResourceList = new List <TeamResource>(); if (TeamNameList == null) { baseResourceList = _connection.Repository.Teams.FindAll(); } else { //Multiple values but one of them is wildcarded, which is not an accepted scenario (I.e -MachineName WebServer*, Database1) if (TeamNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && TeamNameList.Count > 1)) { throw OctoposhExceptions.ParameterCollectionHasRegularAndWildcardItem("TeamName"); } //Only 1 wildcarded value (ie -MachineName WebServer*) else if (TeamNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && TeamNameList.Count == 1)) { var pattern = new WildcardPattern(TeamNameList.First()); baseResourceList = _connection.Repository.Teams.FindMany(t => pattern.IsMatch(t.Name.ToLower())); } //multiple non-wildcared values (i.e. -MachineName WebServer1,Database1) else if (!TeamNameList.Any(WildcardPattern.ContainsWildcardCharacters)) { baseResourceList = _connection.Repository.Teams.FindMany(t => TeamNameList.Contains(t.Name.ToLower())); } } if (ResourceOnly) { if (baseResourceList.Count == 1) { WriteObject(baseResourceList.FirstOrDefault(), true); } else { WriteObject(baseResourceList, true); } } else { var converter = new OutputConverter(); var outputList = converter.GetOctopusTeam(baseResourceList); if (outputList.Count == 1) { WriteObject(outputList.FirstOrDefault(), true); } else { WriteObject(outputList, true); } } }