使用来自 cmd 的参数调用 PowerShell 命令

问题描述

我想从 df2.PwrOut = df1.PwrOut.interpolate('cubic') 调用 PowerShell 命令。例如,将其设为 cmd

PowerShell.exe Command Line Interface

好的,我的情况是

get-content

就我而言,它看起来像

powershell -command <string> [<CommandParameters>]

但它不起作用。我无法理解如何将 powershell -command "& {get-content <???>}" <filepath> arg cmd 传递到命令字符串 <filepath> 中。

解决方法

根据@Abraham Zinala,您可以使用以下内容编写 cmd 文件 test.cmd

powershell -command "Get-Content 'c:\tmp\toto.txt' "

如果你想写:

.\test.cmd c:\tmp\toto.txt

你可以放入你的cmd文件:

powershell -command "Get-Content '%1' "