Powershell---替换文本文件中指定行的整行内容
0 Preface/Foreword
1 替换行内容
#This is a powershell script with extension name ".ps1" which is used for checking if the specified files exist or not
Write-Host "Hello, Powershell script..."
$file_name = "test.txt"
$line_number = 3
$new_content = "OSM"
$ERROR_CODE = 1
if (Test-Path $file_name) {
"bin folder exists.^_^ ^_^ ^_^ "
} else {
"bin folder doesn't exist! &__& &__& &__&"
exit $ERROR_CODE
}$lines = Get-Content $file_name
$lines[$line_number - 1] = $new_content
$lines | Set-Content $file_name -Force