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

write-HostItemDecorator is un-necessarily wrapped #11

Open
plastikfan opened this issue Jun 15, 2020 · 1 comment
Open

write-HostItemDecorator is un-necessarily wrapped #11

plastikfan opened this issue Jun 15, 2020 · 1 comment
Assignees
Labels

Comments

@plastikfan
Copy link
Owner

plastikfan commented Jun 15, 2020

write-HostItemDecorator can easily be turned into a script block obviating the need for the wrapper object. I discovered this as a result of perusing as issue on PSScriptAnalyzer (PowerShell/PSScriptAnalyzer#711 (comment)); a comment by @rjmholt illustrates how to do this:

We can use this technique for passing write-HostItemDecorator as a parameter to invoke-ForeachFile, without powershell mistaing it for in an place invocation of the function.

@plastikfan plastikfan self-assigned this Jun 15, 2020
@plastikfan
Copy link
Owner Author

plastikfan commented Jun 15, 2020

Tested with this line:

[scriptblock]$wrapper = [scriptblock]::Create('write-HostItemDecorator')

but powershell still prompts for parameters:

cmdlet write-HostItemDecorator at command pipeline position 1
Supply values for the following parameters:

... so abandon ship for now!

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

No branches or pull requests

1 participant