【发布时间】:2013-11-20 00:32:43
【问题描述】:
我有一个文本文件,我想从该文件中删除特殊字符。例如:- 文本文件中的条目
++Mathematics
--Chemistry
(Physics)
$#History)
%%Geography
现在我想替换文本文件中字符串中的所有特殊字符,并希望输出为:- 数学 化学 物理 历史 地理
我在我的 powershell 脚本中使用了替换命令,但尽管替换了特殊字符,它还是从我的文本文件中删除了所有值。
get-content D:\Share\SCCM-Powershell_Commands\edit.txt
Foreach-object {$_ -replace "\&", "" -replace "\£", "" -replace "\+", "" -replace "\-", "" -replace "\)","" -replace "\(","" -replace "\$","" -replace "\#","" -replace "\*",""}|
Set-Content D:\Share\SCCM-Powershell_Commands\edit1.txt
get-content D:\Share\SCCM-Powershell_Commands\edit.txt
同时有人可以建议如何开始学习 powershell。我是 powershell 的新手,想学习 Powershell 脚本。
【问题讨论】:
标签: powershell-3.0