PS 5.1.22621.4391 (e estou preso a ele)
Às vezes preciso executar isto:
plink -t -load "$Session" -batch -m $ShellFile
mas às vezes preciso adicionar outra opção:
plink -t -load "$Session" -batch -m $ShellFile -pw $SshPw
Isso parece tão brega, mas no mau sentido:
if ($SshPw)
{ plink -t -load "$Session" -batch -m $ShellFile -pw $SshPw }
else
{ plink -t -load "$Session" -batch -m $ShellFile }
Tentei construir o comando como uma string e depois executá-lo via &
, mas falhou, pois aparentemente o que &
processa é apenas o nome do programa.
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
Existe uma solução alternativa? Meu Google-fu está faltando.