You can read a file without any PSSnapin by using Get-content. And below you can find how to read a file, write on the file, and replace the existing content with new content.
Get-Content -Path "D:\Logs\log20220805.txt"
Add-Content -Path "D:\Logs\log20220805.txt" -Value "new text"
Set-Content -Path "D:\Logs\log20220805.txt" -Value "replace with this text!"
Most popular tags