相关疑难解决方法(0)

如何输入多行命令

是否可以将PowerShell命令行拆分为多行?

在Visual Basic中,我可以使用下划线(_)继续下一行中的命令.

powershell multiline

379
推荐指数
8
解决办法
35万
查看次数

PowerShell命令多行

我有一个如下所示的批处理脚本:

TEST.BAT

@echo off

:: Starts a PowerShell session that starts a PowerShell process with administrator privileges
powershell -noprofile -command "&{$process = start-process powershell -ArgumentList '-noprofile -noexit -file GetTools.ps1' -verb RunAs -PassThru;$process.WaitForExit();}"
Run Code Online (Sandbox Code Playgroud)

为了便于阅读,我想将"&{...}"内的代码拆分为多行.

这篇文章说使用尾随反引用应该可以解决问题,但是当我写下:

powershell -noprofile -command "&{`
    $process = start-process powershell -ArgumentList '-noprofile -noexit -file GetTools.ps1' -verb RunAs -PassThru;`
    $process.WaitForExit();`
}"
Run Code Online (Sandbox Code Playgroud)

...也就是说,我用尾随反引号结束每一行,然后我收到以下错误:

Incomplete string token.
At line:1 char:4
+ &{` <<<<
    + CategoryInfo          : ParserError: (`:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : IncompleteString

'$process' is not recognized as an …
Run Code Online (Sandbox Code Playgroud)

powershell batch-file

9
推荐指数
1
解决办法
1万
查看次数

如何在Powershell控制台中分配多个行字符串

当我在powershell控制台中输入它时

$test=@'
Test
Test'@
Run Code Online (Sandbox Code Playgroud)

并输入几次,它继续打印

>>
Run Code Online (Sandbox Code Playgroud)

所以我永远无法完成命令.

该怎么办 ?

string powershell multiline

7
推荐指数
3
解决办法
5627
查看次数

标签 统计

powershell ×3

multiline ×2

batch-file ×1

string ×1