Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #365 #366

Merged
merged 2 commits into from
Oct 15, 2020
Merged

Fix #365 #366

merged 2 commits into from
Oct 15, 2020

Conversation

jhoneill
Copy link
Contributor

PR Summary

It appears this

               list = Cache.Shell.AddArgument(queries)
                                 .AddCommand("Select-Object")
                                 .AddParameter("ExpandProperty", "Name")
                                 .AddCommand("Sort-Object")
                                 .Invoke<string>();

Is the wrong way to pass queries down the pipeline into select-object and causes
A command is required to add a parameter. A command must be added to the PowerShell instance before adding a parameter.

It's fixed by changed to calling the command like this.

list = Cache.Shell.AddCommand("Select-Object")
                                 .AddParameter("ExpandProperty", "Name")
                                 .AddCommand("Sort-Object")
                                 .Invoke<string>(queries);

PR Checklist

@DarqueWarrior
Copy link
Collaborator

Do you have an example where you get that error? I have not seen that error.

@DarqueWarrior DarqueWarrior merged commit f95ce17 into MethodsAndPractices:trunk Oct 15, 2020
@jhoneill
Copy link
Contributor Author

Do you have an example where you get that error? I have not seen that error.

The completer for queries doesn't use the cache, so I don't think anything is calling it, meaning the error isn't visible - I can't recall why I tried to the access the cache directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants