1
我試圖將兩個參數傳遞給PowerShell中的函數,並且發現奇怪的結果。當我將參數傳遞給一個函數並將它們輸出爲一個組合字符串時,所有參數都顯示在第一個參數的位置。使用括號調用函數時Powershell中的參數
繼承人我的代碼:
$s = "D:\"
$o = "I:\"
function a($source, $output){
Write-Output $source
Write-Output $output
Write-Output "exe $source --parameter $output"
}
Write-Output $s
Write-Output $o
Write-Output "exe $s --parameter $o"
a($s, $o)
輸出:
D:\
I:\
exe D:\ --parameter I:\
D:\
I:\
exe D:\ I:\ --parameter
通知 「I:\」 是在不同的地方
我要調用的函數並得到這個輸出:
D:\
I:\
exe D:\ --parameter I:\
任何人都可以幫我解決如何避免這個問題嗎?