Windows 从批处理文件执行powershell命令时转义双引号

Windows 从批处理文件执行powershell命令时转义双引号,windows,powershell,batch-file,command,escaping,Windows,Powershell,Batch File,Command,Escaping,我必须在PowerShell命令中使用replace命令和regex。Replace with RegEx仅适用于双引号(“)。此外,要在批处理文件中执行PowerShell命令,该命令必须位于双引号(“)内,如下所示: powershell -command "" 那么,有没有一种方法可以转义replace命令使用的双引号,因为由于双引号中存在冲突,下面的命令引发了错误: powershell -command "$content -replace ",$", ",NULL"" 我试过使用

我必须在PowerShell命令中使用replace命令和regex。Replace with RegEx仅适用于双引号(“)。此外,要在批处理文件中执行PowerShell命令,该命令必须位于双引号(“)内,如下所示:

powershell -command ""
那么,有没有一种方法可以转义replace命令使用的双引号,因为由于双引号中存在冲突,下面的命令引发了错误:

powershell -command "$content -replace ",$", ",NULL""
我试过使用(`),比如:


有人能提出一些解决方案吗?

在PowerShell中使用两次双引号符号(即“”)来转义它

echo“这是我的“双引号”测试。”

这将打印:这是我的“双引号”测试

你有没有试过这样的方法:

-command "$content -replace "",$"", "",NULL"""

Replace with regex不仅仅适用于双引号。您是否尝试过
-replace',$,',NULL'
?当然,您也可以尝试使用反斜杠来转义内部双引号,
-replace\“,$\”,\”,NULL\“
-command "$content -replace "",$"", "",NULL"""