【问题标题】:Cannot bind argument to parameter 'Path' because it is null无法将参数绑定到参数“路径”,因为它为空
【发布时间】:2013-10-04 12:20:16
【问题描述】:

如何获取当前正在执行的命令或脚本的当前路径?

尝试了以下脚本:

$scriptpath = $MyInvocation.MyCommand.Path
write-host $scriptpath

这样称呼它:

 invoke-command -computername localhost -filepath .\test.ps1

还尝试了以下方法,但得到一个空行:

invoke-command -scriptblock { write-host $MyInvocation.MyCommand.Path }

【问题讨论】:

标签: powershell


【解决方案1】:

您是否尝试过使用 $pwd 获取路径?

【讨论】:

    猜你喜欢
    • 2020-02-09
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    • 1970-01-01
    相关资源
    最近更新 更多