delete existing reports with same name

This commit is contained in:
2024-02-23 11:52:57 -05:00
parent 9f926a0322
commit cbef3ea79d
+4
View File
@@ -12,6 +12,10 @@ $ReportPathNoExt = "${OutputDirectory}\batteryreport_${Env:COMPUTERNAME}_${Today
$HtmlReportPath = $ReportPathNoExt + '.html'
$XmlReportPath = $ReportPathNoExt + '.xml'
# Delete reports if they already exist
If ( Test-Path $XmlReportPath ) { Remove-Item -Path $XmlReportPath -Force }
If ( Test-Path $HtmlReportPath ) { Remove-Item -Path $HtmlReportPath -Force }
# Generate the XML report
Write-Output "Generating XML battery report: ${XmlReportPath}"
Try { Start-Process "powercfg.exe" -ArgumentList "/batteryreport /output ""${XmlReportPath}"" /xml" -Wait }