Is there a simple way to pass specific *named* PowerShell parameters through directly to a called function?

☆樱花仙子☆ 提交于 2019-12-05 02:29:30

In PowerShell v2 (which admittedly you may not be ready to move to yet) allows you to pass along parameters without knowing about them ahead of time:

called-func $PSBoundParameters

PSBoundParameters is a dictionary of all the parameters that were actually provided to your function. You can remove parameters you don't want (or add I suppose).

Well, I think I was confusing a blog post I read about switch parameters. As far as I can tell the best way is to just reuse the parameters like so:

called-func -foo:$foo -bar:$bar

How about

called-func  $foo $bar
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!