我试图替换文本文件上的一部分。 首先我搜索,如果它出现在文本文件中使用powershell替换文本文件中的字符
$check = Get-Content sample.txt | Where-Object {$_.Contains('<add key="IIS_VERSION" value="7" />')}
if ($checkIISv)
{
Write-Host "IIS's version is already 7"
}
else
{
Write-Host "Update IIS version to 7"
# I want to place here a code that will replace the value="7" if it is not =7
# This value is usually not 7
}
请帮帮忙,我不认为,因为“价值”被认为是未知的替换功能都可以在这里使用。
多数民众赞成也许是最好的解决方案。 –