我正在尝试使用 get-content 从文件中获取内容并使用 add-content 将其添加到现有文件,但问题是我无法将该内容添加到新行。你能对此提出建议吗?
使用以下命令:
Get-content -Path $destRoot1 | Add-Content -Path $destRoot2
最佳答案
您需要将内容设置为目标文件路径,而不是添加内容。请引用以下更改:
$destRoot1 = "C:\File\path1.txt"
$destRoot2 = "C:\destination\path\of\the\file.txt"
Get-content -Path $destRoot1 |Set-Content -Path $destRoot2 -Force
关于powershell - 使用 Add-Content PowerShell 将文本添加到现有文件的新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66566109/