且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多行的PowerShell命令

更新时间:2022-03-22 23:06:22

您可以尝试插入符号^,以指示当前行在下一行继续:

You may try the caret ^ to indicate that the current line continues on the next one:

powershell -noprofile -command "&{"^
 "$process = start-process powershell -ArgumentList '-noprofile -noexit -file GetTools.ps1' -verb RunAs -PassThru;"^
 "$process.WaitForExit();"^
 "}"

请注意每行的开头和结尾处,以及".

Please note also the leading space as well as the closing and opening " on each line.

另请参见 在Windows Vista批处理(.bat)文件中,长命令会分成多行 .

See also Long commands split over multiple lines in Windows Vista batch (.bat) file.