Qas*_*oud 51 windows powershell command-line process cmd.exe
我如何从 cmd 运行此命令:
powershell.exe "(get-process | ? {$_.Description -eq "Sysinter Process Explorer"}) | select processname | out-file $env:APPDATA\example.txt"
我仍然收到此错误:
您必须在“-eq”运算符的右侧提供一个值表达式。在 line:1 char:37 + (get-process | ? {$_.Description -eq <<<< Sysinternals Process Explorer}) | 选择进程名| 输出文件 $env:APPDATA\example.txt + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException +fullyQualifiedErrorId : ExpectedValueExpression
Sim*_*onS 72
powershell -command "get-process | ? {$_.Description -eq 'Sysinter Process Explorer'} | select processname | out-file $env:APPDATA\example.txt"
Run Code Online (Sandbox Code Playgroud)
基本上你有一个 powershell 命令并将它粘贴在这些引号之间以从 CMD 调用它
powershell -command " #PasteCodeHere "
在这些引号中,您必须使用,'否则会中断您的命令参数。
编辑:附加信息:
你经常会遇到这样的情况: powershell -command "& 'somestuff'"
将&用于调用文件。当你只使用一个命令&是不必要的,当你想调用一个脚本时,你应该使用它。
powershell -command "& 'C:\foobar.ps1'"
你也可以powershell -file C:\file.ps1用来调用脚本
| 归档时间: |
|
| 查看次数: |
193611 次 |
| 最近记录: |