powershell - 如何在 Powershell 中将字符串保存为原始数据?

标签 powershell

我想设置一个带有特殊字符的字符串(例如 $)。 如何将字符串保存为原始字符串?

$B = "A$$B"不保存为 "A$$B"。

谢谢。

最佳答案

如果字符串在 '(单引号)中,则变量(如 $x)不会展开。

此外,Powershell 的 here-strings 非常类似于 C# 中的逐字字符串

http://blogs.msdn.com/b/powershell/archive/2006/07/15/variable-expansion-in-strings-and-herestrings.aspx

关于powershell - 如何在 Powershell 中将字符串保存为原始数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6519645/

相关文章:

windows - Powershell 脚本卡住,从批处理文件调用时不退出

windows - Windows Server 2016 TP4上的Docker通过powershell下载容器中的git

windows - Git命令行和批处理文件有不同的输出

powershell - Get-ADUser 中带有变量的通配符

java - 如何将属性从 Powershell 传递给 jar?

powershell - 如何在powershell中查找当前脚本的位置/路径

powershell - 使用 Powershell 更新 IIS 中的主机 header

powershell - Powershell 的 get-counters cmdlet 中返回的 "cooked value"是什么?

用于将 Hyper-V guest 状态保存到磁盘的 Powershell 命令

powershell - 如何将 PowerShell 表达式的结果注册到 DSC 的变量中?