bash $* 的 Powershell 等价物是什么? [英] What is the Powershell equivalent for bash $*?

查看:70
本文介绍了bash $* 的 Powershell 等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

换句话说,我怎样才能获得脚本本身的命令行?

所以,我知道 $PSBoundParameters,但它不一样.我只想按原样获取包含传入参数的字符串.

我该怎么做?

解决方案

$MyInvocation.Line

阅读about_Automatic_Variables:

<块引用>

$MyInvocation包含有关当前命令的信息,例如名称,参数、参数值和有关命令如何执行的信息启动、调用或调用",例如调用的脚本的名称当前命令.$MyInvocation 仅为脚本、函数和脚本块填充.

In other words how can I get the command line of the script itself?

So, I know about $PSBoundParameters, but it is not the same. I just want to get the string containing the passed in parameters as is.

How do I do it?

解决方案

$MyInvocation.Line

Read about_Automatic_Variables:

$MyInvocation
   Contains an information about the current command, such as the name, 
   parameters, parameter values, and information about how the command was
   started, called, or "invoked," such as the name of the script that called
   the current command. 

   $MyInvocation is populated only for scripts, function, and script blocks.

这篇关于bash $* 的 Powershell 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆