假设我正在运行一个带有多个输入参数的 PowerShell 脚本。命令看起来像:
psScript.ps1 -arg1 "arg1value" -arg2 "arg2value"
有没有办法将这个确切的命令存储在脚本中的变量中,以便我可以记录它?
具体来说,我想知道分配给变量 $currentCommand 的内容:
$currentCommand = <something>
Write-Host "currently running script " $currentCommand
这样 Write-Host 输出将是用于调用脚本的确切命令行。例如,如果脚本命令与上述相同,则输出将是:
currently running script psScript.ps1 -arg1 "arg1value" -arg2 "arg2value"
最佳答案
关于powershell - 在 PowerShell 中脚本回显当前命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14283535/