Powershell&;Plink-格式化命令
我正在尝试从powershell脚本中将一些命令推送到plink 我让它工作,除非文件名中有空格Powershell&;Plink-格式化命令,powershell,powershell-2.0,Powershell,Powershell 2.0,我正在尝试从powershell脚本中将一些命令推送到plink 我让它工作,除非文件名中有空格 $entry.name = "File with a space.txt" $SSH_Source = "/share/USBDisk1" $Files = $SSH_Source+$entry.Name 当我按下“$Files以plink”键时,它会截断文件名中的空格 $entry.name = "File with a space.txt" $SSH_Source = "/share/U
$entry.name = "File with a space.txt"
$SSH_Source = "/share/USBDisk1"
$Files = $SSH_Source+$entry.Name
当我按下“$Files
以plink”键时,它会截断文件名中的空格
$entry.name = "File with a space.txt"
$SSH_Source = "/share/USBDisk1"
$Files = $SSH_Source+$entry.Name
我需要它像这样输出单引号,以便plink正确工作
/share/USBDisk1/'File with a space.txt'
提前谢谢,像这样吗
$entry.name = "'File with a space.txt'"
难道你不想做这样的事情:
$entryname = "File with a space.txt"
$SSH_Source = "/share/USBDisk1"
$Files = '"' + $SSH_Source + '/' + $entryname + '"'
$Files
"/share/USBDisk1/File with a space.txt"
您需要在完整路径周围加引号,例如:
$entryname = "File with a space.txt"
$SSH_Source = "/share/USBDisk1"
$Files = '"' + $SSH_Source + '/' + $entryname + '"'
$Files
"/share/USBDisk1/File with a space.txt"
抱歉,忘记提到我正在从名为Name的CSV列中提取文件名。我尝试过用单引号将其包装起来,但都不起作用。请在代码中指定
$entry.name
值的部分发布。如果来自管道,则可以执行以下操作:$entry.name=“$”这里是获取条目值的位置:foreach($CSV中的条目){