I have a script that creates AD reports and then saves them to my desktop. I’ve created another script to attach it as an SMTP email to email myself. I will be setting this script as a scheduled task to run monthly, but want it to overwrite the previous month’s file. (It emails me the attachment with the $date, which I have an email filter set up to save it locally). I always get a prompt that says “A file named XXXXX already exists. Do you want to replace it ?” Can I set it to automatically replace it?
write-Host “Saving file in $env:userprofile\desktop”