PS 5.1.22621.4391(我被它困住了)
有时我需要运行这个:
plink -t -load "$Session" -batch -m $ShellFile
但有时我需要添加另一个选项:
plink -t -load "$Session" -batch -m $ShellFile -pw $SshPw
这看起来太黑客了,但效果不好:
if ($SshPw)
{ plink -t -load "$Session" -batch -m $ShellFile -pw $SshPw }
else
{ plink -t -load "$Session" -batch -m $ShellFile }
我尝试将命令构建为字符串,然后通过执行&
,但失败了,因为显然&
处理的只是程序名称。
PS C:\Users> $X="plink -t -load `"$Session`" -batch -m $ShellFile"
PS C:\Users> $X
plink -t -load "FIS-Q-LBX-PGS-101-a" -batch -m C:\<somedir>\daily.txt
PS C:\Users> &$X
& : The term 'plink -t -load "FIS-Q-LBX-PGS-101-a" -batch -m C:\<somedir>\daily.txt' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2
+ &$X
+ ~~
+ CategoryInfo : ObjectNotFound: (plink -t -load ...\Temp\daily.txt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
有解决方法吗?我的 Google 能力不够强。