![](/img/trans.png)
[英]How do I pass a string parameter to Powershell for ConvertFrom-StringData from command line?
[英]Powershell cannot pass in command line string parameter
\\我已經嘗試了我可以在網上找到的所有內容,但我無法完成這項工作....真的很令人沮喪。 我想要做的就是將命令行中的文件名傳遞給我的Powershell腳本test.ps1。
param([String]$input=$args[0])
$inputpath = 'C:\work\'
$inputfile = $($inputpath + $input+".txt")
我運行腳本如:
powershell。\\ test.ps1“輸入”
但是,在我打印出來的錯誤信息中,我不斷收到“找不到c:\\ work \\ .txt”。 顯然我的命令行參數不正確。 有人可以幫忙嗎?
嘗試將$Input
更改$Input
其他名稱。 因為$Input
用於Pipeline變量。
參見例如:
我只是用它來構建路徑:
$inputpath = 'C:\work\'
$inputfile = Join-Path $inputpath ($args[0] + ".txt")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.