protected override void ProcessRecord()
        {
            var baseResourceList = new List <VariableSetResource>();
            var variableSetIDs   = new List <string>();

            var projectList            = new List <ProjectResource>();
            var libraryVariableSetList = new List <LibraryVariableSetResource>();

            var librarySetNameList = LibrarySetName?.ToList().ConvertAll(s => s.ToLower());

            var projectNameList = ProjectName?.ToList().ConvertAll(s => s.ToLower());

            //If no Project and Library set is declared, return all the things.
            if (projectNameList == null && librarySetNameList == null)
            {
                projectList.AddRange(_connection.Repository.Projects.FindAll());
                libraryVariableSetList.AddRange(_connection.Repository.LibraryVariableSets.FindAll());
            }

            //If at least 1 project or Library variable set is defined, then just return that list instead of everything.
            else
            {
                #region Getting projects
                //Getting variable set ids from projects

                if (projectNameList != null)
                {
                    //Multiple values but one of them is wildcarded, which is not an accepted scenario (I.e -MachineName WebServer*, Database1)
                    if (projectNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && projectNameList.Count > 1))
                    {
                        throw OctoposhExceptions.ParameterCollectionHasRegularAndWildcardItem("ProjectName");
                    }
                    //Only 1 wildcarded value (ie -MachineName WebServer*)
                    else if (projectNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && projectNameList.Count == 1))
                    {
                        var pattern = new WildcardPattern(projectNameList.First());
                        projectList.AddRange(_connection.Repository.Projects.FindMany(t => pattern.IsMatch(t.Name.ToLower())));
                    }
                    //multiple non-wildcared values (i.e. -MachineName WebServer1,Database1)
                    else if (!projectNameList.Any(WildcardPattern.ContainsWildcardCharacters))
                    {
                        projectList.AddRange(_connection.Repository.Projects.FindMany(t => projectNameList.Contains(t.Name.ToLower())));
                    }
                }
                #endregion

                #region Getting Library variable sets
                if (librarySetNameList != null)
                {
                    //Getting variable set ids from LibraryVariableSets

                    //Multiple values but one of them is wildcarded, which is not an accepted scenario (I.e -MachineName WebServer*, Database1)
                    if (librarySetNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && librarySetNameList.Count > 1))
                    {
                        throw OctoposhExceptions.ParameterCollectionHasRegularAndWildcardItem("LibrarySetName");
                    }
                    //Only 1 wildcarded value (ie -MachineName WebServer*)
                    else if (librarySetNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && librarySetNameList.Count == 1))
                    {
                        var pattern = new WildcardPattern(librarySetNameList.First());
                        libraryVariableSetList.AddRange(_connection.Repository.LibraryVariableSets.FindMany(t => pattern.IsMatch(t.Name.ToLower())));
                    }
                    //multiple non-wildcared values (i.e. -MachineName WebServer1,Database1)
                    else if (!librarySetNameList.Any(WildcardPattern.ContainsWildcardCharacters))
                    {
                        libraryVariableSetList.AddRange(_connection.Repository.LibraryVariableSets.FindMany(t => librarySetNameList.Contains(t.Name.ToLower())));
                    }
                }
                #endregion
            }

            variableSetIDs.AddRange(libraryVariableSetList.Select(v => v.VariableSetId));
            variableSetIDs.AddRange(projectList.Select(p => p.VariableSetId));

            //This works
            foreach (var id in variableSetIDs)
            {
                baseResourceList.Add(_connection.Repository.VariableSets.Get(id));
            }

            //This doesn't work and throws: [Exception thrown: 'Octopus.Client.Exceptions.OctopusResourceNotFoundException' in Octopus.Client.dll]
            //Github issue for this https://github.com/OctopusDeploy/Issues/issues/3307
            //baseResourceList.AddRange(_connection.Repository.VariableSets.Get(variableSetIDs.ToArray()));

            if (ResourceOnly)
            {
                if (baseResourceList.Count == 1)
                {
                    WriteObject(baseResourceList.FirstOrDefault(), true);
                }
                else
                {
                    WriteObject(baseResourceList, true);
                }
            }

            else
            {
                var converter  = new OutputConverter();
                var outputList = converter.GetOctopusVariableSet(baseResourceList, projectList, libraryVariableSetList, IncludeUsage);

                if (outputList.Count == 1)
                {
                    WriteObject(outputList.FirstOrDefault(), true);
                }
                else
                {
                    WriteObject(outputList, true);
                }
            }
        }