I am new to powershell. how do you over write file in powershell? write now below code is appending. I want to completely over write file with below new info.
$someinfo | Add-Content $FileName
Use Set-Content
instead of Add-Content
.
Difference between Set-Content
and Add-Content
:Add-Content
=> AppendSet-Content
=> replace content
Reference:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-content?view=powershell-5.1
You can do an Out-File
as well
'Some content' | Out-File -FilePath c:\windows\temp\file.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With