Would like to find a way to automatically backup the web.config file of a website without having to go into the script and change the path. Backup-WebConfiguration backs up the website files but not the web.config. We are setting a script that adds changes for CPS text and would like to bakup the file before the text is applied. Here is a example:
$site = “”
$currentDate = (get-date).tostring("mm_dd_yyyy-hh_mm") # month_day_year - hours_mins
$backup = $Website + "_$currentDate"
# Get the content of the config file and cast it to XML and save a backup copy labeled .bak followed by the date
$xml = [xml](get-ChildItem $Website)
#save a backup copy
$xml.Save($backup)